summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-02-12 08:54:23 +0200
committerTim Graham <timograham@gmail.com>2016-02-15 09:26:58 -0500
commit33b5bb79308c26615f55dc5eef85deb25f741ce2 (patch)
treeee9abbe5b6933b9b5216cbe95fd8b364acf936ff
parent2b28a2123240f5d4adacaa2c74916d35ab1b38ac (diff)
[1.9.x] Fixed #26126 -- Fixed transient failure of test_max_age_expiration
Backport of b17a9150a0c3a132e82b53755ede62a45f897875 from master
-rw-r--r--tests/requests/tests.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/requests/tests.py b/tests/requests/tests.py
index 93c04da422..843094fdf9 100644
--- a/tests/requests/tests.py
+++ b/tests/requests/tests.py
@@ -14,7 +14,7 @@ from django.http import (
)
from django.test import RequestFactory, SimpleTestCase, override_settings
from django.test.client import FakePayload
-from django.test.utils import str_prefix
+from django.test.utils import freeze_time, str_prefix
from django.utils import six
from django.utils.encoding import force_str
from django.utils.http import cookie_date, urlencode
@@ -206,10 +206,12 @@ class RequestsTests(SimpleTestCase):
def test_max_age_expiration(self):
"Cookie will expire if max_age is provided"
response = HttpResponse()
- response.set_cookie('max_age', max_age=10)
+ set_cookie_time = time.time()
+ with freeze_time(set_cookie_time):
+ response.set_cookie('max_age', max_age=10)
max_age_cookie = response.cookies['max_age']
self.assertEqual(max_age_cookie['max-age'], 10)
- self.assertEqual(max_age_cookie['expires'], cookie_date(time.time() + 10))
+ self.assertEqual(max_age_cookie['expires'], cookie_date(set_cookie_time + 10))
def test_httponly_cookie(self):
response = HttpResponse()