Skip to content

Instantly share code, notes, and snippets.

@bwangelme
Created September 9, 2016 09:36
Show Gist options
  • Save bwangelme/286c55472d8642b741ae6dba62bb8b09 to your computer and use it in GitHub Desktop.
Save bwangelme/286c55472d8642b741ae6dba62bb8b09 to your computer and use it in GitHub Desktop.
tornado单元测试
import tornado.testing
from tornado.testing import AsyncTestCase
from tornado.testing import AsyncHTTPClient
from tornado.testing import unittest
class MyTestCase(AsyncTestCase):
@tornado.testing.gen_test
def test_http_fetch(self):
client = AsyncHTTPClient(self.io_loop)
response = yield client.fetch("http://www.tornadoweb.org")
self.assertIn(b"FriendFeed", response.body)
if __name__ == '__main__':
unittest.main()
@besky86
Copy link

besky86 commented Jan 3, 2017

from tornado.testing import AsyncHTTPClient 错了,应该是from tornado.httpclient import AsyncHTTPClient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment