Last active
March 15, 2018 03:49
-
-
Save ityoung/7ad6a47b514886ce4f6707d1c8db3450 to your computer and use it in GitHub Desktop.
A code snippet of unittest in tornado and motorengine.
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.web import Application | |
from tornado.testing import AsyncHTTPTestCase | |
from apps.account.handlers import CheckEnv | |
import unittest | |
import motorengine | |
class MyTestCase(AsyncHTTPTestCase): | |
def setUp(self, auto_connect=True): | |
super(MyTestCase, self).setUp() | |
if auto_connect: | |
self.db = motorengine.connect("test", host="192.168.3.158", port=27017, io_loop=self.io_loop) | |
def tearDown(self): | |
motorengine.connection.cleanup() | |
super(MyTestCase, self).tearDown() | |
def get_app(self): | |
return Application([(r"/account/check-env/", CheckEnv)]) | |
def test_example(self): | |
res = self.fetch("/account/check-env/") | |
print(res.body) | |
if __name__ == "__main__": | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment