Last active
November 14, 2018 11:45
-
-
Save adamrecsko/26b1d6c65a100d19d7e664d0338c1d74 to your computer and use it in GitHub Desktop.
Run standard python3 async unittests in the main event loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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