diff --git a/pytest_asyncio_cooperative/plugin.py b/pytest_asyncio_cooperative/plugin.py index 863cb67..0f189dd 100644 --- a/pytest_asyncio_cooperative/plugin.py +++ b/pytest_asyncio_cooperative/plugin.py @@ -304,10 +304,17 @@ def sync_wrapper(): result = None def run_in_thread(): nonlocal result - result = asyncio.run(new_task) + try: + result = asyncio.run(new_task) + except Exception as e: + result = e thread = threading.Thread(target=run_in_thread) thread.start() thread.join() + + if isinstance(result, Exception): + raise result # type: ignore + return result item.runtest = sync_wrapper