Skip to content

Fix warning filter precedence across test scopes - #15087

Open
K-kiron wants to merge 1 commit into
pytest-dev:mainfrom
K-kiron:fix/10406-warning-marker-priority
Open

K-kiron wants to merge 1 commit into
pytest-dev:mainfrom
K-kiron:fix/10406-warning-marker-priority

Conversation

@K-kiron

@K-kiron K-kiron commented Sep 23, 2026

Copy link
Copy Markdown

With a class-level filterwarnings("error") mark, a parameter marked filterwarnings("ignore") still fails. The class filter is applied after the parameter filter and ends up taking precedence. The same issue affects module-level filters.

I changed warning filtering to apply outer-scope filters first, keeping the existing order within each node. This lets more specific filters override the defaults without changing shared marker iteration or storage.

The regression tests cover conflicting filters across scopes, existing decorator and argument ordering, and parameter-specific overrides. I also documented the precedence and added a changelog entry.

Fixes #10406.

Running python -m pytest testing/test_warnings.py testing/test_mark.py testing/python/metafunc.py -q --tb=short on Windows with Python 3.11.5 gives 338 passed, 4 skipped, and 1 xfailed. Pre-commit also passes for the changed files.

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Sep 23, 2026
@K-kiron

K-kiron commented Sep 23, 2026

Copy link
Copy Markdown
Author

The PyPy job fails in TestMetafunc.test_idval_hypothesis while Hypothesis imports numpy.random, with a CYTHON_USE_TYPE_SPECS=1 RuntimeWarning.

I found the same failure in #15086:
https://github.com/pytest-dev/pytest/actions/runs/35784033528/job/106936914376

Both runs use PyPy 8.0.0, while the passing main run used PyPy 7.3.23. This looks like a PyPy/NumPy compatibility issue. The other 29 test matrix jobs passed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@pytest.mark.* priority seems wrong

1 participant