diff options
-rw-r--r-- | tests/utilities.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/utilities.py b/tests/utilities.py index 2f5d2611..438cb798 100644 --- a/tests/utilities.py +++ b/tests/utilities.py @@ -16,6 +16,7 @@ """Helpers for unittests themselves.""" +import asyncio import functools import unittest @@ -186,3 +187,14 @@ def expected_failure(func): """ func.todo = 'expected failure' return func + + +def async_test(coro): + """Run an asyncrounous test synchronously.""" + + @functools.wraps(coro) + def _actual(*args, **kwargs): + loop = asyncio.get_event_loop() + return loop.run_until_complete(coro(*args, **kwargs)) + + return _actual |