From ea4570da5714deac86d6438ebac3f0b2ecea1ee6 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Thu, 5 Dec 2013 21:54:29 -0500 Subject: [PATCH] cookies: Fix bugs found during CI --- requests/cookies.py | 3 ++- test_requests.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/requests/cookies.py b/requests/cookies.py index af33b2e..35dacfc 100644 --- a/requests/cookies.py +++ b/requests/cookies.py @@ -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']), diff --git a/test_requests.py b/test_requests.py index d999a48..de61fd5 100755 --- a/test_requests.py +++ b/test_requests.py @@ -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.""" -- 2.7.4