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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DeprecationWarning if sync test requests async fixture #12930
base: main
Are you sure you want to change the base?
DeprecationWarning if sync test requests async fixture #12930
Changes from 4 commits
6728ec5
5c41d50
8e100ea
283db4e
5beab07
2d06ff2
0de5302
1891fed
6b9de2a
94dd153
b19fd52
987904c
70639ef
7256c0c
c98ef2b
cd3eb98
2d9bb86
876cc2a
1a4dfbb
d35e4eb
ef096cd
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure this is the place to do the check, and am also not 100% it can't be triggered by a sync fixture requesting an async fixture. But for the latter I think it's covered by the
self.scope == "function"
check, where ifself
is a fixture requesting another fixture it's because it's higher-scoped.So while this appears to function robustly, it might be making somewhat sketchy assumptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is correct, and I also see a test for this, so I guess we are good.
Check warning on line 610 in src/_pytest/fixtures.py
Codecov / codecov/patch
src/_pytest/fixtures.py#L610
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the test name to "Sync test '{name}'" and the fixture name to "async fixture '{name}'" in the phrase here to help users understand the problem better.
We also should add an entry to "deprecations", with the rationale for this and guiding users on how to update their code (installing plugins, changing the
async
fixture, etc).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was confused for a second what you meant with "installing plugins". The way the error for async test functions handles it is by printing a long message recommending async test plugins, maybe this message should do the same. Not sure it has much of a place in the deprecations doc - if a user has a test suite that currently works the fix almost surely whouldn't be to install a new async test plugin.
Check warning on line 621 in src/_pytest/fixtures.py
Codecov / codecov/patch
src/_pytest/fixtures.py#L621