Skip to content

Add --warnings-collapse-threshold to control warning location collapsing - #14985

Open
V1SHAL421 wants to merge 2 commits into
pytest-dev:mainfrom
V1SHAL421:warnings-collapse-threshold
Open

Add --warnings-collapse-threshold to control warning location collapsing#14985
V1SHAL421 wants to merge 2 commits into
pytest-dev:mainfrom
V1SHAL421:warnings-collapse-threshold

Conversation

@V1SHAL421

Copy link
Copy Markdown
Contributor

Closes #14983

Once a warning message reaches 10 locations, pytest collapses the output to filenames only — dropping the test node IDs entirely. This is counterproductive: the more warnings you have, the more you need to know which tests are responsible. The threshold of 10 is hardcoded with no way to change it per-project.

This solution makes the threshold configurable via --warnings-collapse-threshold (CLI) and warnings_collapse_threshold (INI/TOML). Defaults to 10 so existing behaviour is completely preserved. Set to none to never collapse — always show full test node IDs regardless of count. Invalid values (zero, negative, non-numeric) are rejected at argument-parse time with a clear error message.

Checklist

  • Include documentation when adding new features.
  • Include new tests or update existing tests when appl
  • Allow maintainers to push and squash when merging my commits.
  • Add text like closes Allow disabling aggregation of warnings by filename #14983 to the PR description.
  • If AI agents were used, they are credited in Co-authored-by commit trailers.
  • Create a new changelog file (changelog/14983.feature
  • Add yourself to AUTHORS in alphabetical order.

AI assistance

This contribution was developed with the assistance of Claude (Anthropic). All code has been reviewed and understood by the author.

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Sep 7, 2026
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.

Allow disabling aggregation of warnings by filename

1 participant