Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Properly configure async tests #17311
Copy link
Copy link
Open
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: processA process-related concern. May include testing, release, or the like.A process-related concern. May include testing, release, or the like.
Description
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: processA process-related concern. May include testing, release, or the like.A process-related concern. May include testing, release, or the like.
A recent release of
pytest-asyncio(v1.4.0) caused several tests to fail withRuntimeError: There is no current event loop in thread 'MainThread'(see comment here).As a quick workaround, PR #17260 introduced a temporary autouse fixture to manually manage the event loop:
The Correct Long-Term Fix
This workaround is a stopgap. The root cause is that tests containing asynchronous code are missing the proper
async defdeclaration and the@pytest.mark.asynciomarker.The correct long-term solution is to properly decorate and define these tests. For example, PR #17308 resolved this error (CI run logs) by properly updating the test definitions (see commit diff).
Next Steps
Please keep this issue open until the temporary
set_event_loopfixture is entirely removed from the codebase and all affected tests are properly refactored withasync defand@pytest.mark.asyncio.