Improved test architecture #139
This commit is contained in:
parent
75c316f2d2
commit
77d723b9da
@ -2,14 +2,13 @@ import asyncio
|
|||||||
|
|
||||||
|
|
||||||
class Async:
|
class Async:
|
||||||
_loop = None
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def test(cls, coro):
|
def test(cls, coro):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
if cls._loop is None:
|
try:
|
||||||
cls._loop = asyncio.get_event_loop()
|
return asyncio.run(coro(*args, **kwargs))
|
||||||
|
except Exception as e:
|
||||||
return cls._loop.run_until_complete(coro(*args, **kwargs))
|
return
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
Loading…
Reference in New Issue
Block a user