Skip to content

Commit 76910ca

Browse files
authored
Fix --show-capture with --tb=line (#13868)
Fixes #13865
1 parent 0e1b42a commit 76910ca

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ Yusuke Kadowaki
501501
Yutian Li
502502
Yuval Shimon
503503
Zac Hatfield-Dodds
504+
Zac Palmer Laporte
504505
Zach Snicker
505506
Zachary Kneupper
506507
Zachary OBrien

changelog/13865.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed `--show-capture` with `--tb=line`.

src/_pytest/terminal.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ def summary_failures_combined(
11881188
if style == "line":
11891189
for rep in reports:
11901190
line = self._getcrashline(rep)
1191+
self._outrep_summary(rep)
11911192
self.write_line(line)
11921193
else:
11931194
for rep in reports:

testing/test_terminal.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,19 @@ def test_func():
15871587
assert "--calling--" not in s
15881588
assert "IndexError" not in s
15891589

1590+
def test_tb_line_show_capture(self, pytester: Pytester, option) -> None:
1591+
output_to_capture = "help! let me out!"
1592+
pytester.makepyfile(
1593+
f"""
1594+
import pytest
1595+
def test_fail():
1596+
print('{output_to_capture}')
1597+
assert False
1598+
"""
1599+
)
1600+
result = pytester.runpytest("--tb=line")
1601+
result.stdout.fnmatch_lines(["*- Captured stdout call -*", output_to_capture])
1602+
15901603
def test_tb_crashline(self, pytester: Pytester, option) -> None:
15911604
p = pytester.makepyfile(
15921605
"""

0 commit comments

Comments
 (0)