Fix pytest class-scoped fixture deprecation warning in extract_permissions tests - #71002
Merged
Conversation
…sions tests pytest 9.1 deprecates defining a class-scoped fixture as a plain instance method, since attributes set on self in the fixture aren't visible to test methods (each test gets a new instance while the fixture runs once per class). test_extract_permissions.py had two such fixtures, all_entries and rst_content, triggering PytestRemovedIn10Warning on every run. Neither fixture actually relied on self, so marking them as @classmethod removes the warning with no behavior change.
eladkal
requested review from
amoghrajesh,
ashb,
bugraoz93,
gopidesupavan,
jason810496,
jscheffl and
potiuk
as code owners
August 3, 2026 16:06
potiuk
approved these changes
Aug 3, 2026
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.
Running
scripts/tests/ci/prek/test_extract_permissions.pysurfaces:for the class-scoped all_entries fixture in TestExtractAllPermissions
and the rst_content fixture in TestRenderRst. pytest 9.1 deprecates
this pattern because attributes set on self in a class-scoped fixture
aren't visible to test methods — pytest creates a new instance per
test while the fixture runs once per class — and the warning will
become an error in pytest 10.
Both fixtures here just return a computed value and never touch self,
so the fix is mechanical: decorate each with
@classmethodand takecls instead of self, per pytest's documented migration path.
No test behavior changes — all 70 tests in the file still pass with
no warnings.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude (Sonnet 4.5) following the guidelines