- commit
- 116ba89dc51c76830b78f598282a4116bcbc47bf
- parent
- 1a4ef15979e9893595edc6c58d64e845b4872348
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2019-02-09 07:47
add async_test decorator
Diffstat
| M | pyt/decorators.py | 18 | +++++++++++++++--- |
1 files changed, 15 insertions, 3 deletions
diff --git a/pyt/decorators.py b/pyt/decorators.py
@@ -1,14 +1,26 @@ -1 1 import asyncio -1 2 1 3 from .expect import expect 2 4 3 5 4 6 def fail(fn):5 -1 def wrapper():-1 7 def wrapper(*args, **kwargs): 6 8 with expect.raises(AssertionError):7 -1 fn()-1 9 fn(*args, **kwargs) 8 10 return wrapper 9 11 10 12 11 13 def skip(fn):12 -1 def wrapper():-1 14 def wrapper(*args, **kwargs): 13 15 pass 14 16 return wrapper -1 17 -1 18 -1 19 def async_test(fn): -1 20 def wrapper(*args, **kwargs): -1 21 coro = asyncio.coroutine(fn) -1 22 future = coro(*args, **kwargs) -1 23 loop = asyncio.get_event_loop() -1 24 loop.run_until_complete(future) -1 25 loop.close() -1 26 return wrapper