Skip to content

Commit 9560d20

Browse files
authored
Fix deprecated call to utcnow() (#51)
* Fix deprecated call to utcnow() * @grahamalama review
1 parent 4000db2 commit 9560d20

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

src/autograph_utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import binascii
1212
import re
1313
from abc import ABC
14-
from datetime import datetime
14+
from datetime import datetime, timezone
1515

1616
import cryptography
1717
import ecdsa.util
@@ -508,4 +508,4 @@ def _now():
508508
509509
:returns: naive datetime representing a UTC timestamp
510510
"""
511-
return datetime.utcnow()
511+
return datetime.now(tz=timezone.utc)

tests/test_autograph_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ async def test_verify_signature_bad_numbers(aiohttp_session, mock_with_x5u, cach
180180
await s.verify(SIGNED_DATA, SAMPLE_SIGNATURE[:-4], FAKE_CERT_URL)
181181

182182

183-
async def test_verify_x5u_expired(aiohttp_session, mock_with_x5u, cache, now_fixed):
184-
now_fixed.return_value = datetime.datetime(2022, 10, 23, 16, 16, 16, tzinfo=timezone.utc)
183+
async def test_verify_x5u_expired(aiohttp_session, mock_with_x5u, cache):
185184
s = SignatureVerifier(aiohttp_session, cache, DEV_ROOT_HASH)
186185
with pytest.raises(autograph_utils.CertificateExpired) as excinfo:
187186
await s.verify(SIGNED_DATA, SAMPLE_SIGNATURE, FAKE_CERT_URL)

0 commit comments

Comments
 (0)