Created
November 11, 2014 17:50
-
-
Save ajdavis/69b12c7ee77d6ae010d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tornado.testing import AsyncHTTPTestCase, gen_test | |
from tornado.web import Application | |
from tornado.web import RequestHandler | |
from tornado.gen import coroutine, Return | |
class HelloHandler(RequestHandler): | |
@coroutine | |
def get(self): | |
msg = yield self.task() | |
self.write(msg) | |
@coroutine | |
def task(self): | |
raise Return('Hello world!') | |
class HelloHandlerTest(AsyncHTTPTestCase): | |
def get_app(self): | |
return Application( | |
[(r'/', HelloHandler)], | |
) | |
@gen_test | |
def test_one(self): | |
res = yield self.http_client.fetch(self.get_url('/')) | |
assert res.error is None, 'error: %s' % str(res.error) | |
import unittest | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: