fix: only warn about asyncio_default_fixture_loop_scope when needed#1507
Closed
pctablet505 wants to merge 4 commits into
Closed
fix: only warn about asyncio_default_fixture_loop_scope when needed#1507pctablet505 wants to merge 4 commits into
pctablet505 wants to merge 4 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1507 +/- ##
==========================================
- Coverage 94.50% 93.81% -0.70%
==========================================
Files 2 2
Lines 510 517 +7
Branches 62 63 +1
==========================================
+ Hits 482 485 +3
- Misses 22 26 +4
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
|
Closing this after taking another look at the wider discussion. The comment on #1344 already leaned toward finishing the deprecation rather than making the warning conditional, and that work is underway in #1444 (default the fixture loop scope to function and drop the warning entirely, per #924, targeted at v1.4.0). Once that lands this warning path goes away, so a conditional-suppression workaround here isn't worth review time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1344
When pytest-asyncio is installed as a transitive dependency, the plugin currently emits its
PytestDeprecationWarningabout an unsetasyncio_default_fixture_loop_scopeunconditionally frompytest_configure. That means any test suite running under-Werrorwill hit an internal error as soon as pytest-asyncio is present, even if the suite has no async tests or fixtures. The reporter saw this withpytester.runpytest_inprocess, but the underlying issue is that the warning fires the moment the plugin loads.As noted in the issue thread, this happens because pytest enables all installed plugins by default. The suggested workaround of passing
-p no:asyncioworks, but it is not reasonable to expect users who never chose to install pytest-asyncio to discover and apply it.This change moves the warning into
pytest_fixture_setup, so it is only emitted when an async fixture is actually being set up and neither the globalasyncio_default_fixture_loop_scopenor a per-fixtureloop_scopehas been configured. AStashKeyon theConfigobject keeps track of whether the warning has already been emitted, preventing it from repeating for every async fixture.I added regression tests for both sides of the behavior: a plain synchronous test now passes under
-Werrorwithout triggering the warning, while a suite that does use an async fixture still sees the deprecation warning as expected.