summaryrefslogtreecommitdiff
path: root/tests/regressiontests/requests/tests.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-03-18 20:58:22 +0000
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-03-18 20:58:22 +0000
commitc8e2f7591d6ea3545aeb32fa4c92cbeb9a622546 (patch)
tree85567aca5535ddfaaed1f1dcc11218288cb446ff /tests/regressiontests/requests/tests.py
parentc7cc4cfb9ebef17930db4a92cd0632a536a4ff7a (diff)
Fixed #17931 -- Accepted aware datetimes to set cookies expiry dates. Thanks jaddison for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17766 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/requests/tests.py')
-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()