Skip to content

terminal: add --name-only option to show only names of failed tests #14452

@Vlor999

Description

@Vlor999

What's the problem this feature will solve?

When running large test suites, failed tests often produce a significant amount of output including tracebacks, captured logs, and stdout/stderr. If many tests fail simultaneously, identifying the specific tests that failed becomes difficult as the names are buried under pages of detailed error information. While options like -q or --tb=no exist, they often hide too much information or don't provide the structured "FAILURES" and "ERRORS" sections that help in quickly scanning results.

Describe the solution you'd like

A new command-line option --name-only that modifies the terminal output to only show the names of failed or erring tests.

When enabled:

  • The FAILURES section lists only the test names (e.g., test_fail1).
  • The ERRORS section lists the error headlines (e.g., ERROR at setup of test_error or ERROR collecting test_file.py).
  • All detailed tracebacks and captured output sections are suppressed for these failures.

Example output:

   1 ============================= FAILURES =============================
   2 test_fail1
   3 test_fail2
   4 ====================== short test summary info ======================
   5 FAILED test_file.py::test_fail1 - assert False
   6 FAILED test_file.py::test_fail2 - assert False
   7 ========================= 2 failed in 0.05s =========================

Alternative Solutions

  • Using --tb=no or --tb=line: These reduce output but either remove the summary headers entirely or still include error messages that can be quite verbose.
  • Piping to grep: Users often pipe pytest output to grep to extract failure names, but this is fragile and loses pytest's color formatting and structural grouping.

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