1
+ import zoneinfo
2
+
1
3
import pytest
2
4
from django .contrib .auth import get_user_model
3
5
from django .core .signing import SignatureExpired
@@ -14,7 +16,7 @@ def test_unsign(self, db, signer, signature):
14
16
user = get_user_model ().objects .create_user (
15
17
pk = 1337 ,
16
18
email = "spiderman@avengers.com" ,
17
- last_login = timezone .datetime (2002 , 5 , 3 , tzinfo = timezone . utc ),
19
+ last_login = timezone .datetime (2002 , 5 , 3 , tzinfo = zoneinfo . ZoneInfo ( "UTC" ) ),
18
20
)
19
21
assert user == signer .unsign (signature )
20
22
@@ -29,7 +31,7 @@ def test_unsign__last_login(self, db, signer, signature):
29
31
pk = 1337 ,
30
32
email = "spiderman@avengers.com" ,
31
33
# later date, that does not match the signature
32
- last_login = timezone .datetime (2012 , 7 , 3 , tzinfo = timezone . utc ),
34
+ last_login = timezone .datetime (2012 , 7 , 3 , tzinfo = zoneinfo . ZoneInfo ( "UTC" ) ),
33
35
)
34
36
with pytest .raises (
35
37
SignatureExpired ,
@@ -42,7 +44,7 @@ def test_unsing__single_use(self, db, signer, signature):
42
44
pk = 1337 ,
43
45
email = "spiderman@avengers.com" ,
44
46
# later date, that does not match the signature (token was used)
45
- last_login = timezone .datetime (2012 , 7 , 3 , tzinfo = timezone . utc ),
47
+ last_login = timezone .datetime (2012 , 7 , 3 , tzinfo = zoneinfo . ZoneInfo ( "UTC" ) ),
46
48
)
47
49
assert user == signer .unsign (signature , single_use = False )
48
50
# test a second time to make sure token can be used more than one time
@@ -54,7 +56,7 @@ def test_unsing__single_use(self, db, signer, signature):
54
56
signer .unsign (signature , single_use = True )
55
57
56
58
def test_to_timestamp (self ):
57
- value = timezone .datetime (2002 , 5 , 3 , tzinfo = timezone . utc )
59
+ value = timezone .datetime (2002 , 5 , 3 , tzinfo = zoneinfo . ZoneInfo ( "UTC" ) )
58
60
base62_value = signing .UserSigner .to_timestamp (value = value )
59
61
assert base62_value == "173QUS"
60
62
0 commit comments