本文整理汇总了Python中tornado.testing.AsyncHTTPTestCase方法的典型用法代码示例。如果您正苦于以下问题:Python testing.AsyncHTTPTestCase方法的具体用法?Python testing.AsyncHTTPTestCase怎么用?Python testing.AsyncHTTPTestCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.testing
的用法示例。
在下文中一共展示了testing.AsyncHTTPTestCase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tornado_testcase
# 需要导入模块: from tornado import testing [as 别名]
# 或者: from tornado.testing import AsyncHTTPTestCase [as 别名]
def tornado_testcase(request):
# Take the unittest class provided by tornado and manually call its setUp
# and tearDown.
#
# The pytest plugins for tornado seem too complicated to use, as they for
# some reason assume I want to write my tests in async code.
def inner(app):
class TestBogus(AsyncHTTPTestCase):
def get_app(self):
return app
def bogustest(self):
# We need to pass a valid test method name to the ctor, so this
# is the method. It does nothing.
pass
self = TestBogus("bogustest")
self.setUp()
request.addfinalizer(self.tearDown)
return self
return inner
示例2: test_tear_down_releases_app_and_http_server
# 需要导入模块: from tornado import testing [as 别名]
# 或者: from tornado.testing import AsyncHTTPTestCase [as 别名]
def test_tear_down_releases_app_and_http_server(self):
result = unittest.TestResult()
class SetUpTearDown(AsyncHTTPTestCase):
def get_app(self):
return Application()
def test(self):
self.assertTrue(hasattr(self, "_app"))
self.assertTrue(hasattr(self, "http_server"))
test = SetUpTearDown("test")
test.run(result)
self.assertFalse(hasattr(test, "_app"))
self.assertFalse(hasattr(test, "http_server"))