Skip to content

docs: show how to apply warning filters conditionally - #15274

Open
shoka-jp wants to merge 2 commits into
pytest-dev:mainfrom
shoka-jp:docs/conditional-warning-filters
Open

shoka-jp wants to merge 2 commits into
pytest-dev:mainfrom
shoka-jp:docs/conditional-warning-filters

Conversation

@shoka-jp

Copy link
Copy Markdown

Add a Windows-specific filterwarnings example using pytest_collection_modifyitems and item.add_marker(). This lets users ignore a known warning on one platform while retaining their existing warning policy elsewhere. The text also explains that collection-time import warnings are outside the example's scope.

Related to #7525; this documents an existing workaround and does not add environment-marker syntax to configuration files.

Validation:

  • Executed the snippet extracted from the documentation with Python 3.11.8, pytest 9.2.0 and filterwarnings = error. The matching-platform case ignored the known warning while an unrelated warning still failed; the nonmatching case failed on both warnings as expected.
  • Full Sphinx HTML build passed with -W --keep-going.
  • git diff --check passed.

Prepared with Codex assistance under human direction; AI attribution is included in the commit trailer.

  • Allow maintainers to push and squash when merging my commits.
  • AI agent credited in Co-authored-by commit trailer.

shoka-jp and others added 2 commits October 28, 2026 13:15
Add a platform-specific filterwarnings recipe using collection hooks.

Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-authored-by: OpenAI Codex <noreply@openai.com>
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 28, 2026

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.

1 participant