Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Endre Galaczi
Eric Hunsberger
Eric Liu
Eric Siegerman
Eric Yuan
Erik Aronesty
Erik Hasse
Erik M. Bray
Expand Down Expand Up @@ -432,6 +433,7 @@ Xixi Zhao
Xuan Luong
Xuecong Liao
Yannick Péroux
Yao Xiao
Yoav Caspi
Yuliang Shao
Yusuke Kadowaki
Expand Down
1 change: 1 addition & 0 deletions changelog/11777.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Text is no longer truncated in the ``short test summary info`` section when ``-vv`` is given.
6 changes: 3 additions & 3 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,11 +1408,11 @@ def _get_line_with_reprcrash_message(
except AttributeError:
pass
else:
if not running_on_ci():
if running_on_ci() or config.option.verbose >= 2:
msg = f" - {msg}"
else:
available_width = tw.fullwidth - line_width
msg = _format_trimmed(" - {}", msg, available_width)
else:
msg = f" - {msg}"
if msg is not None:
line += msg

Expand Down
46 changes: 44 additions & 2 deletions testing/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2377,8 +2377,13 @@ def mock_get_pos(*args):

monkeypatch.setattr(_pytest.terminal, "_get_node_id_with_markup", mock_get_pos)

class Namespace:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)

class config:
pass
def __init__(self):
self.option = Namespace(verbose=0)

class rep:
def _get_verbose_word(self, *args):
Expand All @@ -2399,7 +2404,7 @@ def markup(self, word: str, **markup: str):
if msg:
rep.longrepr.reprcrash.message = msg # type: ignore
actual = _get_line_with_reprcrash_message(
config, # type: ignore[arg-type]
config(), # type: ignore[arg-type]
rep(), # type: ignore[arg-type]
DummyTerminalWriter(), # type: ignore[arg-type]
{},
Expand Down Expand Up @@ -2443,6 +2448,43 @@ def markup(self, word: str, **markup: str):
check("🉐🉐🉐🉐🉐\n2nd line", 80, "FAILED nodeid::🉐::withunicode - 🉐🉐🉐🉐🉐")


def test_short_summary_with_verbose(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HolyMagician03-UMich took the liberty of simplifying this test. 👍

monkeypatch: MonkeyPatch, pytester: Pytester
) -> None:
"""With -vv do not truncate the summary info (#11777)."""
# On CI we also do not truncate the summary info, monkeypatch it to ensure we
# are testing against the -vv flag on CI.
monkeypatch.setattr(_pytest.terminal, "running_on_ci", lambda: False)

string_length = 200
pytester.makepyfile(
f"""
def test():
s1 = "A" * {string_length}
s2 = "B" * {string_length}
assert s1 == s2
"""
)

# No -vv, summary info should be truncated.
result = pytester.runpytest()
result.stdout.fnmatch_lines(
[
"*short test summary info*",
"* assert 'AAA...",
],
)

# No truncation with -vv.
result = pytester.runpytest("-vv")
result.stdout.fnmatch_lines(
[
"*short test summary info*",
f"*{'A' * string_length}*{'B' * string_length}'",
]
)


@pytest.mark.parametrize(
"seconds, expected",
[
Expand Down