Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced the 'datetime.utcnow()' method with 'datetime.now(timezone.utc)' #210

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading