summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/requests/tests.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py
index d4239448dd..b7a4788ec5 100644
--- a/tests/regressiontests/requests/tests.py
+++ b/tests/regressiontests/requests/tests.py
@@ -12,6 +12,7 @@ from django.http import HttpRequest, HttpResponse, parse_cookie, build_request_r
from django.test.utils import get_warnings_state, restore_warnings_state
from django.utils import unittest
from django.utils.http import cookie_date
+from django.utils.timezone import utc
class RequestsTests(unittest.TestCase):
@@ -207,6 +208,15 @@ class RequestsTests(unittest.TestCase):
datetime_cookie = response.cookies['datetime']
self.assertEqual(datetime_cookie['max-age'], 10)
+ def test_aware_expiration(self):
+ "Cookie accepts an aware datetime as expiration time"
+ response = HttpResponse()
+ expires = (datetime.utcnow() + timedelta(seconds=10)).replace(tzinfo=utc)
+ time.sleep(0.001)
+ response.set_cookie('datetime', expires=expires)
+ datetime_cookie = response.cookies['datetime']
+ self.assertEqual(datetime_cookie['max-age'], 10)
+
def test_far_expiration(self):
"Cookie will expire when an distant expiration time is provided"
response = HttpResponse()