pytest-dev / pytest-dev/pytest

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

Open
#14,452 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

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.
PR

PR

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing pytest's terminal output implementation and the linked PR #14451. The work is done when --name-only lists failed test names and error headlines while suppressing detailed tracebacks and captured output, without removing the FAILURES and ERRORS sections.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.