1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #33562 -- Made HttpResponse.set_cookie() support timedelta for the max_age argument.

This commit is contained in:
Luke Plant
2022-03-04 12:57:10 +00:00
committed by Mariusz Felisiak
parent 1882f6567d
commit ae2da5ba65
5 changed files with 29 additions and 4 deletions

View File

@@ -71,6 +71,11 @@ class SetCookieTests(SimpleTestCase):
response.set_cookie("max_age", max_age=10.6)
self.assertEqual(response.cookies["max_age"]["max-age"], 10)
def test_max_age_timedelta(self):
response = HttpResponse()
response.set_cookie("max_age", max_age=timedelta(hours=1))
self.assertEqual(response.cookies["max_age"]["max-age"], 3600)
def test_httponly_cookie(self):
response = HttpResponse()
response.set_cookie("example", httponly=True)