Skip to content

Allow disabling aggregation of warnings by filename #14983

Open

Description

@adamsol

What's the problem this feature will solve?

Currently, when tests raise 10 or more warnings in total, the warnings are aggregated to display only the filenames they come from, without test ids.

pytest/src/_pytest/terminal.py

Lines 1126 to 1135 in 431f3e1

if len(locations) < 10:
return "\n".join(map(str, locations))
counts_by_filename = Counter(
str(loc).split("::", 1)[0] for loc in locations
)
return "\n".join(
"{}: {} warning{}".format(k, v, "s" if v > 1 else "")
for k, v in counts_by_filename.items()
)

This is counterproductive when we actually have a lot of warnings to fix in the code, because we don't know which tests / fragments of code raise them.

Describe the solution you'd like

A configuration setting to change the currently hardcoded limit (10) or disable it.

Alternative Solutions

A possible workaround is to use asserts instead of warnings.

Activity

  1. seanxuu commented on Sep 7, 2026

    @seanxuu

    I’d like to work on this. I plan to trace pytest’s warning aggregation and filename grouping, add a focused regression test for the configurable limit/disabled behavior, and make the smallest configuration change that preserves the current default. Please let me know if this direction fits the project.

  2. V1SHAL421 commented on Sep 7, 2026

    @V1SHAL421
    Contributor

    As the issue describes, the real pain is that once you hit 10 warnings you lose the test IDs entirely - which is exactly when you need them most, since that's when you have the most warnings to track down. A minimal patch to tweak the constant doesn't help because the right threshold varies by project. The PR I am going to link makes it configurable via --warnings-collapse-threshold, keeps 10 as the default so nothing breaks and adds none to disable collapsing entirely for anyone who just wants full visibility.

  3. added a commit that references this issue on Sep 7, 2026
    a7a0eaf
  4. RonnyPfannschmidt commented on Sep 21, 2026

    @RonnyPfannschmidt
    Member

    for reference my #6833 added the initial treshold

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions