fix: Truncate short test summary to first line of error message if not in verbose mode. by V1SHAL421 · Pull Request #14261 · pytest-dev/pytest

Summary

Closes #14063

Ensure that the short test summary displays exactly one line per failure by truncating multi-line error messages to their first line.

Currently, pytest prints the full assertion message in the short summary. When the message spans multiple lines (e.g. NumPy tolerance diffs), the summary can expand to hundreds of lines, making it difficult to scan.

This change truncates failure messages in the short summary to the first line only when verbosity is below -vv (config.verbose < 2), preserving full messages when running with -vv.

Problem

When running pytest with verbose output (-v), the short test summary may contain extremely long multi-line assertion messages.

For example, in the NumPy test suite, 17 failing tests generated more than 900 lines in the short summary because each failure included full multi-line assertion diffs.

Solution

The short test summary now truncates failure messages to their first line when config.verbose < 2.
Implementation:

if config.verbose < 2:
    message = reprcrash.message.splitlines()[0]