summaryrefslogtreecommitdiff
path: root/tests/responses
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2021-05-07 10:42:59 +0100
committerCarlton Gibson <carlton.gibson@noumenal.es>2021-05-12 11:08:41 +0200
commitd06c5b358149c02a62da8a5469264d05f29ac659 (patch)
tree2ca0d6884062980dea5e8085af0868f9d9b5a266 /tests/responses
parent69ffb1acf38bd34f76707468bb592eb4b164e2da (diff)
Fixed #32366 -- Updated datetime module usage to recommended approach.
- Replaced datetime.utcnow() with datetime.now(). - Replaced datetime.utcfromtimestamp() with datetime.fromtimestamp(). - Replaced datetime.utctimetuple() with datetime.timetuple(). - Replaced calendar.timegm() and datetime.utctimetuple() with datetime.timestamp().
Diffstat (limited to 'tests/responses')
-rw-r--r--tests/responses/test_cookie.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/responses/test_cookie.py b/tests/responses/test_cookie.py
index fd3a55442c..96dd603aac 100644
--- a/tests/responses/test_cookie.py
+++ b/tests/responses/test_cookie.py
@@ -19,7 +19,7 @@ class SetCookieTests(SimpleTestCase):
# evaluated expiration time and the time evaluated in set_cookie(). If
# this difference doesn't exist, the cookie time will be 1 second
# larger. The sleep guarantees that there will be a time difference.
- expires = datetime.utcnow() + timedelta(seconds=10)
+ expires = datetime.now(tz=utc).replace(tzinfo=None) + timedelta(seconds=10)
time.sleep(0.001)
response.set_cookie('datetime', expires=expires)
datetime_cookie = response.cookies['datetime']
@@ -28,7 +28,7 @@ class SetCookieTests(SimpleTestCase):
def test_aware_expiration(self):
"""set_cookie() accepts an aware datetime as expiration time."""
response = HttpResponse()
- expires = (datetime.utcnow() + timedelta(seconds=10)).replace(tzinfo=utc)
+ expires = datetime.now(tz=utc) + timedelta(seconds=10)
time.sleep(0.001)
response.set_cookie('datetime', expires=expires)
datetime_cookie = response.cookies['datetime']