Skip to content

Commit

Permalink
Merge pull request #210 from Guri-X/main
Browse files Browse the repository at this point in the history
Replaced the 'datetime.utcnow()' method with 'datetime.now(timezone.utc)'
  • Loading branch information
sigmavirus24 committed May 6, 2024
2 parents 7a92bf1 + 38fcd93 commit 8f3d284
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/betamax/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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).replace(tzinfo=None)
if re_record_interval < (now - self.cassette.earliest_recorded_date):
self.cassette.clear()

Expand Down
4 changes: 2 additions & 2 deletions src/betamax/util.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -163,7 +163,7 @@ def add_urllib3_response(serialized, response, headers):


def timestamp():
stamp = datetime.utcnow().isoformat()
stamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S")
try:
i = stamp.rindex('.')
except ValueError:
Expand Down

0 comments on commit 8f3d284

Please sign in to comment.