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.coroutine
cannot be used on tests because the .IOLoop is not already running.@gen_test
should 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_test
times out after 5 seconds. The timeout may be overridden globally with theASYNC_TEST_TIMEOUT
environment variable, or for each test with thetimeout
keyword 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
timeout
argument andASYNC_TEST_TIMEOUT
environment variable.Changed in version 4.0: The wrapper now passes along
*args, **kwargs
so it can be used on functions with arguments.