Skip to content

Commit 03ee1b1

Browse files
committed
fix: Yield loop from event_loop fixture to avoid violating function signature.
This prevents gc.collect() from being unreachable. Signed-off-by: Michael Seifert <[email protected]>
1 parent b7f1a16 commit 03ee1b1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pytest_asyncio/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def pytest_runtest_setup(item: pytest.Item) -> None:
494494
@pytest.fixture
495495
def event_loop(request: "pytest.FixtureRequest") -> Iterator[asyncio.AbstractEventLoop]:
496496
"""Create an instance of the default event loop for each test case."""
497-
return asyncio.get_event_loop_policy().new_event_loop()
497+
yield asyncio.get_event_loop_policy().new_event_loop()
498498
# Call the garbage collector to trigger ResourceWarning's as soon
499499
# as possible (these are triggered in various __del__ methods).
500500
# Without this, resources opened in one test can fail other tests

0 commit comments

Comments
 (0)