pytest-dev / pytest-dev/pytest-asyncio
PytestAssertRewriteWarning due to runpytest and pytest_plugins
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 207
- Avg merge
- 5h 35m
- Merged PRs (30d)
- 9
Description
Originally posted by @McSinyx in https://github.com/pytest-dev/pytest-asyncio/issues/1275#issuecomment-3737477316
On Python 3.11 on Guix (full test log), PytestAssertRewriteWarning resurfaces for the following tests due to 18afc9df5a3153dc1fbdc4e11a56517ef95480df replacing runpytest with runpytest_subprocess:
tests/markers/test_class_scope.py::test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set
tests/markers/test_function_scope.py::test_warns_when_scope_argument_is_present
tests/markers/test_module_scope.py::test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set
tests/markers/test_session_scope.py::test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set
tests/test_event_loop_fixture.py::test_event_loop_fixture_handles_unclosed_async_gen
tests/test_event_loop_fixture.py::test_event_loop_fixture_asyncgen_error
IIUC this commit tries to workaround a case in GH-1227 where a system pytest-asyncio package takes precedence over a local one. Our fix for Guix also involves removing pytest_plugins = 'pytest_asyncio' in the following tests because it also marks the package for assertion rewriting while it's already imported before executing the scripts as part of plugin autodiscovery.
tests/test_event_loop_fixture.py::test_event_loop_fixture_handles_unclosed_async_gen
tests/test_event_loop_fixture.py::test_event_loop_fixture_asyncgen_error
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
Start with the six named tests under tests/markers/ and tests/test_event_loop_fixture.py, then compare their runpytest_subprocess usage with commit 18afc9df5a3153dc1fbdc4e11a56517ef95480df. Run the affected tests on Python 3.11 and inspect how pytest_plugins and plugin autodiscovery interact. Done means the listed tests no longer emit PytestAssertRewriteWarning while retaining their existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100