Skip to content

Commit 5ebd1ec

Browse files
authored
junitxml: do not print summary with --quiet (#13702)
Fix #13700
1 parent 2baa197 commit 5ebd1ec

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

changelog/13700.improvement.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`--junitxml` no longer prints the `generated xml file` summary at the end of the pytest session when `--quiet` is given.

src/_pytest/junitxml.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,11 @@ def pytest_sessionfinish(self) -> None:
674674
testsuites.append(suite_node)
675675
logfile.write(ET.tostring(testsuites, encoding="unicode"))
676676

677-
def pytest_terminal_summary(self, terminalreporter: TerminalReporter) -> None:
678-
terminalreporter.write_sep("-", f"generated xml file: {self.logfile}")
677+
def pytest_terminal_summary(
678+
self, terminalreporter: TerminalReporter, config: pytest.Config
679+
) -> None:
680+
if config.get_verbosity() >= 0:
681+
terminalreporter.write_sep("-", f"generated xml file: {self.logfile}")
679682

680683
def add_global_property(self, name: str, value: object) -> None:
681684
__tracebackhide__ = True

testing/test_junitxml.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,3 +1822,13 @@ def test_func():
18221822
assert junit_logging == "no"
18231823
assert len(node.find_by_tag("system-err")) == 0
18241824
assert len(node.find_by_tag("system-out")) == 0
1825+
1826+
1827+
def test_no_message_quiet(pytester: Pytester) -> None:
1828+
"""Do not show the summary banner when --quiet is given (#13700)."""
1829+
pytester.makepyfile("def test(): pass")
1830+
result = pytester.runpytest("--junitxml=pytest.xml")
1831+
result.stdout.fnmatch_lines("* generated xml file: *")
1832+
1833+
result = pytester.runpytest("--junitxml=pytest.xml", "--quiet")
1834+
result.stdout.no_fnmatch_line("* generated xml file: *")

0 commit comments

Comments
 (0)