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
1 change: 1 addition & 0 deletions changelog/4040.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Exclude empty reports for passed tests when ``-rP`` option is used.
7 changes: 4 additions & 3 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,9 +745,10 @@ def summary_passes(self):
return
self.write_sep("=", "PASSES")
for rep in reports:
msg = self._getfailureheadline(rep)
self.write_sep("_", msg)
self._outrep_summary(rep)
if rep.sections:
msg = self._getfailureheadline(rep)
self.write_sep("_", msg)
self._outrep_summary(rep)

def print_teardown_sections(self, rep):
showcapture = self.config.option.showcapture
Expand Down
14 changes: 11 additions & 3 deletions testing/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,22 @@ def test_pass_reporting_on_fail(testdir):
def test_pass_output_reporting(testdir):
testdir.makepyfile(
"""
def test_pass_output():
def test_pass_has_output():
print("Four score and seven years ago...")
def test_pass_no_output():
pass
"""
)
result = testdir.runpytest()
assert "Four score and seven years ago..." not in result.stdout.str()
s = result.stdout.str()
assert "test_pass_has_output" not in s
assert "Four score and seven years ago..." not in s
assert "test_pass_no_output" not in s
result = testdir.runpytest("-rP")
result.stdout.fnmatch_lines(["Four score and seven years ago..."])
result.stdout.fnmatch_lines(
["*test_pass_has_output*", "Four score and seven years ago..."]
)
assert "test_pass_no_output" not in result.stdout.str()


def test_color_yes(testdir):
Expand Down