asyncflux.testing – Unit testing support for asynchronous code¶
Unit testing support for asynchronous code
-
class
asyncflux.testing.AsyncfluxTestCase(methodName='runTest', **kwargs)[source]¶ Bases:
tornado.testing.AsyncTestCase
-
asyncflux.testing.gen_test(func=None, timeout=None)[source]¶ Testing equivalent of
@gen.coroutine, to be applied to test methods.@gen.coroutinecannot be used on tests because the .IOLoop is not already running.@gen_testshould be applied to test methods on subclasses of AsyncTestCase.Example:
class MyTest(AsyncHTTPTestCase): @gen_test def test_something(self): response = yield gen.Task(self.fetch('/'))
By default,
@gen_testtimes out after 5 seconds. The timeout may be overridden globally with theASYNC_TEST_TIMEOUTenvironment variable, or for each test with thetimeoutkeyword argument:class MyTest(AsyncHTTPTestCase): @gen_test(timeout=10) def test_something_slow(self): response = yield gen.Task(self.fetch('/'))
New in version 3.1: The
timeoutargument andASYNC_TEST_TIMEOUTenvironment variable.Changed in version 4.0: The wrapper now passes along
*args, **kwargsso it can be used on functions with arguments.