Slide 33
Slide 33 text
Tests
Rewrite tests in asynchronous with this snippet:
def _async_test(f):
@wraps(f)
def wrapper(self, *args, **kwargs):
if not self.loop.is_running():
coro = asyncio.coroutine(f)
future = coro(self, *args, **kwargs)
self.loop.run_until_complete(asyncio.wait_for(future, 2, loop=self.loop))
else:
return f(self, *args, **kwargs)
return wrapper