From 834816132e8ab04a3cff1afec410e63cb167d605 Mon Sep 17 00:00:00 2001 From: Guri-X Date: Sun, 21 Apr 2024 16:00:52 +0530 Subject: [PATCH] Replaced the 'datetime.utcnow()' method with 'datetime.now(timezone.utc)' --- src/betamax/adapter.py | 4 ++-- src/betamax/util.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/betamax/adapter.py b/src/betamax/adapter.py index 8e8a0d2..2165484 100644 --- a/src/betamax/adapter.py +++ b/src/betamax/adapter.py @@ -9,7 +9,7 @@ from . import cassette from .exceptions import BetamaxError -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from requests.adapters import BaseAdapter, HTTPAdapter _SENTINEL = object() @@ -102,7 +102,7 @@ def load_cassette(self, cassette_name, serialize, options): if self.options.get('re_record_interval'): re_record_interval = timedelta(self.options['re_record_interval']) - now = datetime.utcnow() + now = datetime.now(timezone.utc) if re_record_interval < (now - self.cassette.earliest_recorded_date): self.cassette.clear() diff --git a/src/betamax/util.py b/src/betamax/util.py index 3090acc..fab092b 100644 --- a/src/betamax/util.py +++ b/src/betamax/util.py @@ -1,5 +1,5 @@ from .mock_response import MockHTTPResponse -from datetime import datetime +from datetime import datetime, timezone from requests.models import PreparedRequest, Response from requests.packages.urllib3 import HTTPResponse from requests.structures import CaseInsensitiveDict @@ -163,7 +163,7 @@ def add_urllib3_response(serialized, response, headers): def timestamp(): - stamp = datetime.utcnow().isoformat() + stamp = datetime.now(timezone.utc).isoformat().split("+")[0] try: i = stamp.rindex('.') except ValueError: