diff --git a/AUTHORS b/AUTHORS index 5849228200b..83509281035 100644 --- a/AUTHORS +++ b/AUTHORS @@ -501,6 +501,7 @@ Yusuke Kadowaki Yutian Li Yuval Shimon Zac Hatfield-Dodds +Zac Palmer Laporte Zach Snicker Zachary Kneupper Zachary OBrien diff --git a/changelog/13865.bugfix.rst b/changelog/13865.bugfix.rst new file mode 100644 index 00000000000..f7cd94c2a30 --- /dev/null +++ b/changelog/13865.bugfix.rst @@ -0,0 +1 @@ +Fixed `--show-capture` with `--tb=line`. diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index e65279dcfab..158558b4571 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -1188,6 +1188,7 @@ def summary_failures_combined( if style == "line": for rep in reports: line = self._getcrashline(rep) + self._outrep_summary(rep) self.write_line(line) else: for rep in reports: diff --git a/testing/test_terminal.py b/testing/test_terminal.py index cfc668fa6ad..ee540b65135 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -1587,6 +1587,19 @@ def test_func(): assert "--calling--" not in s assert "IndexError" not in s + def test_tb_line_show_capture(self, pytester: Pytester, option) -> None: + output_to_capture = "help! let me out!" + pytester.makepyfile( + f""" + import pytest + def test_fail(): + print('{output_to_capture}') + assert False + """ + ) + result = pytester.runpytest("--tb=line") + result.stdout.fnmatch_lines(["*- Captured stdout call -*", output_to_capture]) + def test_tb_crashline(self, pytester: Pytester, option) -> None: p = pytester.makepyfile( """