pytest-dev / pytest-dev/pytest-asyncio
Warn when a fixture for a different loop_scope is requested
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 207
- Avg merge
- 5h 35m
- Merged PRs (30d)
- 9
Description
Pytest-asyncio currently allows requesting fixtures that have a different loop_scope than the requesting test or fixture. Since fixtures with different loop scopes use different asyncio event loops, this can lead to unexpected errors., e.g. trying to access a task that was created on a different loop.
This can happen when:
- a test requests a fixture, but the loop_scopes don't match
- a fixture requests another fixture, but the loop_scopes don't match
Mixing fixtures with different loop scopes is almost certainly a user error and should result in a warning.
Work on this issue was done during the pytest sprint 2026, sponsored by Omicron.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test entry point is named in the issue. Start by locating pytest-asyncio's loop_scope handling and follow how fixture dependencies are resolved for tests and fixtures. Done means a warning is emitted for mismatched loop scopes in both cases, with coverage for each scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 56/100