Improved test architecture #139

This commit is contained in:
Sven Heidemann 2022-11-27 10:56:02 +01:00
parent 75c316f2d2
commit 77d723b9da

View File

@ -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