diff --git a/tests/conftest.py b/tests/conftest.py index 8e0cf546f..3bcab2a2b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -114,7 +114,12 @@ def fail_test_on_unclosed_tasks(request: FixtureRequest): """ fail_count = request.session.testsfailed - loop = asyncio.get_event_loop() + try: + loop = asyncio.get_running_loop() + except RuntimeError: + loop = asyncio.new_event_loop() + + asyncio.set_event_loop(loop) loop.set_debug(True) request.addfinalizer(