Skip to content

Commit

Permalink
Fixed test.
Browse files Browse the repository at this point in the history
  • Loading branch information
leekchan committed Sep 16, 2014
1 parent 11ec299 commit b18c0c6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tornado/test/web_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from tornado.template import DictLoader
from tornado.testing import AsyncHTTPTestCase, ExpectLog, gen_test
from tornado.test.util import unittest
from tornado.util import u, ObjectDict, unicode_type
from tornado.util import u, ObjectDict, unicode_type, timedelta_to_seconds
from tornado.web import RequestHandler, authenticated, Application, asynchronous, url, HTTPError, StaticFileHandler, _create_signature_v1, create_signed_value, decode_signed_value, ErrorHandler, UIModule, MissingArgumentError, stream_request_body, Finish, removeslash, addslash

import binascii
Expand Down Expand Up @@ -241,12 +241,13 @@ def test_set_cookie_max_age(self):
def test_set_cookie_expires_days(self):
response = self.fetch("/set_expires_days")
header = response.headers.get("Set-Cookie")
self.assertTrue(re.match("foo=bar; expires=(.+); Path=/", header))
match = re.match("foo=bar; expires=(?P<expires>.+); Path=/", header)
self.assertIsNotNone(match)

expires = datetime.datetime.utcnow() + datetime.timedelta(days=10)
header_expires = datetime.datetime(*email.utils.parsedate(
header[17:header.find("; Path=/")])[:6])
self.assertTrue(expires - header_expires < datetime.timedelta(seconds=10))
header_expires = datetime.datetime(
*email.utils.parsedate(match.groupdict()["expires"])[:6])
self.assertTrue(abs(timedelta_to_seconds(expires - header_expires)) < 10)


class AuthRedirectRequestHandler(RequestHandler):
Expand Down

0 comments on commit b18c0c6

Please sign in to comment.