Skip to content

Allow disabling aggregation of warnings by filename #14983

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

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