cookies: Fix bugs found during CI

This commit is contained in:
Michael Becker
2013-12-05 21:54:29 -05:00
parent ef5875cc19
commit ea4570da57
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -384,7 +384,8 @@ def morsel_to_cookie(morsel):
expires = time.time() + morsel['max-age']
elif morsel['expires']:
time_template = '%a, %d-%b-%Y %H:%M:%S GMT'
expires = time.mktime(time.strptime(morsel['expires'], time_template))
expires = time.mktime(
time.strptime(morsel['expires'], time_template)) - time.timezone
return create_cookie(
comment=morsel['comment'],
comment_url=bool(morsel['comment']),
+2 -2
View File
@@ -1016,7 +1016,7 @@ class TestMorselToCookieExpires(unittest.TestCase):
morsel = Morsel()
morsel['expires'] = 'Thu, 01-Jan-1970 00:00:01 GMT'
cookie = morsel_to_cookie(morsel)
self.assertEquals(cookie.expires, 18001)
self.assertEquals(cookie.expires, 1)
def test_expires_invalid_int(self):
"""Test case where an invalid type is passed for expires."""
@@ -1051,7 +1051,7 @@ class TestMorselToCookieMaxAge(unittest.TestCase):
morsel = Morsel()
morsel['max-age'] = 60
cookie = morsel_to_cookie(morsel)
self.assertIsInstance(cookie.expires, int)
self.assertTrue(isinstance(cookie.expires, int))
def test_max_age_invalid_str(self):
"""Test case where a invalid max age is passed."""