Skip to content

Commit ea4af84

Browse files
committed
Display "short test summary info" before (main) warnings
Fixes pytest-dev#3952.
1 parent 9dec146 commit ea4af84

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/_pytest/terminal.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,10 @@ def pytest_sessionfinish(self, exitstatus):
647647
def pytest_terminal_summary(self):
648648
self.summary_errors()
649649
self.summary_failures()
650-
yield
651650
self.summary_warnings()
651+
yield
652652
self.summary_passes()
653+
self.summary_warnings("warnings summary (during shutdown)")
653654

654655
def pytest_keyboard_interrupt(self, excinfo):
655656
self._keyboardinterrupt_memo = excinfo.getrepr(funcargs=True)
@@ -720,7 +721,7 @@ def getreports(self, name):
720721
values.append(x)
721722
return values
722723

723-
def summary_warnings(self):
724+
def summary_warnings(self, title="warnings summary"):
724725
if self.hasopt("w"):
725726
all_warnings = self.stats.get("warnings")
726727
if not all_warnings:
@@ -730,7 +731,7 @@ def summary_warnings(self):
730731
all_warnings, key=lambda wr: wr.get_location(self.config)
731732
)
732733

733-
self.write_sep("=", "warnings summary", yellow=True, bold=False)
734+
self.write_sep("=", title, yellow=True, bold=False)
734735
for location, warning_records in grouped:
735736
# legacy warnings show their location explicitly, while standard warnings look better without
736737
# it because the location is already formatted into the message

testing/test_terminal.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,11 @@ def pytest_terminal_summary(terminalreporter):
10761076
)
10771077
result = testdir.runpytest()
10781078
result.stdout.fnmatch_lines(
1079-
["*conftest.py:3:*internal warning", "*== 1 warnings in *"]
1079+
[
1080+
"*= warnings summary (during shutdown) =*",
1081+
"*conftest.py:3:*internal warning",
1082+
"*== 1 warnings in *",
1083+
]
10801084
)
10811085
assert "None" not in result.stdout.str()
10821086

0 commit comments

Comments
 (0)