From 39f20605c599268c7eeea6b33dbd0d53b7f6d0cb Mon Sep 17 00:00:00 2001 From: nekokatt <52883826+nekokatt@users.noreply.github.com> Date: Wed, 12 Feb 2020 11:27:13 +0000 Subject: [PATCH] Update plugin.py to enable asyncio debugging Changed plugin.py to enable debug on the event loop fixture. This allows any tasks that are not closed correctly to be logged in such a way that we can see which test they originate from, which is incredibly useful in testing large libraries where a test somewhere may not be awaiting something correctly or may be closing the event loop without terminating tasks correctly. --- pytest_asyncio/plugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 39b9c698..3cdbeba2 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -170,6 +170,7 @@ def pytest_runtest_setup(item): def event_loop(request): """Create an instance of the default event loop for each test case.""" loop = asyncio.get_event_loop_policy().new_event_loop() + loop.set_debug(True) yield loop loop.close()