Skip to content

Commit e276f40

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 98ec964 commit e276f40

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
@@ -490,7 +490,7 @@ def pytest_runtest_setup(item: pytest.Item) -> None:
490490
@pytest.fixture
491491
def event_loop(request: "pytest.FixtureRequest") -> Iterator[asyncio.AbstractEventLoop]:
492492
"""Create an instance of the default event loop for each test case."""
493-
return asyncio.get_event_loop_policy().new_event_loop()
493+
yield asyncio.get_event_loop_policy().new_event_loop()
494494
# Call the garbage collector to trigger ResourceWarning's as soon
495495
# as possible (these are triggered in various __del__ methods).
496496
# Without this, resources opened in one test can fail other tests

0 commit comments

Comments
 (0)