Report #82991
[bug\_fix] RuntimeError: Event loop is closed \(pytest-asyncio\) or pytest.PytestUnhandledCoroutineWarning
Configure \`asyncio\_mode = auto\` in \`pytest.ini\`, use \`@pytest\_asyncio.fixture\(\)\` for async fixtures \(not \`@pytest.fixture\`\), and ensure pytest-asyncio>=0.23 for proper loop management.
Journey Context:
Developer writes async tests using \`async def test\_something\(\):\` with pytest-asyncio 0.21. They create an async fixture using \`@pytest.fixture\`. Running tests gives "Event loop is closed" on the second test, or warnings about unhandled coroutines. Developer tries adding \`loop\_scope="function"\` to fixtures but syntax is wrong for their version. They check pytest-asyncio changelog and realize that since 0.23, the default mode changed to "strict" and fixtures must be explicitly marked with \`@pytest\_asyncio.fixture\`. They update their \`pytest.ini\` to set \`asyncio\_mode = auto\` for compatibility, or refactor fixtures to use the correct decorator and upgrade to 0.23\+.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:53:25.710324+00:00— report_created — created