Skip to content

Instantly share code, notes, and snippets.

@adamrecsko
Last active November 14, 2018 11:45
Show Gist options
  • Save adamrecsko/26b1d6c65a100d19d7e664d0338c1d74 to your computer and use it in GitHub Desktop.
Save adamrecsko/26b1d6c65a100d19d7e664d0338c1d74 to your computer and use it in GitHub Desktop.
Run standard python3 async unittests in the main event loop
from functools import wraps
def async_test():
"""
class ExampleTest(unittest.TestCase):
@async_test()
async test_something():
pass
"""
def decorator(f):
@wraps(f)
def method(test_case, *args, **kwargs):
asyncio.get_event_loop().run_until_complete(f(test_case, *args, **kwargs))
return method
return decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment