Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

Commit

Permalink
Merge pull request #19 from tobigue/feature/test-3.4
Browse files Browse the repository at this point in the history
All tests pass on Python 3.4
  • Loading branch information
truemped committed Aug 24, 2015
2 parents c39850a + d9bdcb3 commit c4e2706
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
18 changes: 10 additions & 8 deletions test/test_requesthandler.py
Expand Up @@ -144,8 +144,11 @@ class EncodingTestingHandler(s.RequestHandler):

@s.async
def get(self, *args, **kwargs):
json_args = json.dumps(args)
json_kwargs = json.dumps(kwargs)
r = SimpleMessage({"doc_id": 'test123',
"message": 'args=%s; kwargs=%s' % (args, kwargs)})
"message": 'args=%s; kwargs=%s' % (json_args,
json_kwargs)})
raise s.Return(r)


Expand All @@ -163,19 +166,19 @@ def test_latinone_handler(self):
response = self.fetch('/testencoding/alfredo-p%e9rez-rubalcaba')
self.assertEqual(200, response.code)
self.assertEqual('{"doc_id": "test123", "message": "' +
'args=(u\'alfredo-p\\\\xe9rez-' +
'rubalcaba\',); kwargs={}"}',
'args=[\\"alfredo-p\\\\u00e9rez-rubalcaba\\"]; ' +
'kwargs={}"}',
json.dumps(json.loads(response.body.decode('utf8')),
sort_keys=True))

def test_utfeight_handler(self):
response = self.fetch('/testencoding/alfredo-p%C3%A9rez-rubalcaba')
self.assertEqual(200, response.code)
self.assertEqual('{"doc_id": "test123", "message": "' +
'args=(u\'alfredo-p\\\\xe9rez-' +
'rubalcaba\',); kwargs={}"}',
'args=[\\"alfredo-p\\\\u00e9rez-rubalcaba\\"]; ' +
'kwargs={}"}',
json.dumps(json.loads(response.body.decode('utf8')),
sort_keys=True).encode('utf8'))
sort_keys=True))


class TestSimpleHtmlHandler(AsyncHTTPTestCase):
Expand Down Expand Up @@ -210,8 +213,7 @@ def test_simple_html(self):
exp_html = ("<html>\n<head><title>Test</title></head>\n" +
"<body>\ndoc_id: test123\nmessage: bliblablup\n" +
"</body>\n</html>\n")
assert exp_html == response.body.decode('utf8')
self.assertEqual(exp_html, response.body)
self.assertEqual(exp_html, response.body.decode('utf8'))


class TestSimpleHtmlHandlerWithMissingTemplate(AsyncHTTPTestCase):
Expand Down
11 changes: 8 additions & 3 deletions test/test_service.py
Expand Up @@ -150,9 +150,14 @@ def test_graceful_shutdown_pending_callbacks(self, ioloop_instance_mock):

service.shutdown()

expected.extend([mock.call(), mock.call().remove_handler(mock.ANY),
mock.call()._callbacks.__nonzero__(),
mock.call().add_timeout(mock.ANY, mock.ANY)])
if sys.version_info < (3,):
expected.extend([mock.call(), mock.call().remove_handler(mock.ANY),
mock.call()._callbacks.__nonzero__(),
mock.call().add_timeout(mock.ANY, mock.ANY)])
else:
expected.extend([mock.call(), mock.call().remove_handler(mock.ANY),
mock.call()._callbacks.__bool__(),
mock.call().add_timeout(mock.ANY, mock.ANY)])
assert expected == ioloop_instance_mock.mock_calls

@mock.patch('tornado.ioloop.IOLoop.instance')
Expand Down

0 comments on commit c4e2706

Please sign in to comment.