Skip to content

Commit 407b330

Browse files
split up report header lines
i found it painful to read crammed in a single line thus rootdir, config file and testpaths now have own lines
1 parent 431ec6d commit 407b330

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

changelog/10727.improvement.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Split the report header for ``rootdir``, ``config file`` and ``testpaths`` so each has its own line.

src/_pytest/terminal.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -739,16 +739,14 @@ def _write_report_lines_from_hooks(
739739
self.write_line(line)
740740

741741
def pytest_report_header(self, config: Config) -> List[str]:
742-
line = "rootdir: %s" % config.rootpath
742+
result = [f"rootdir: {config.rootpath}"]
743743

744744
if config.inipath:
745-
line += ", configfile: " + bestrelpath(config.rootpath, config.inipath)
745+
result.append("configfile: " + bestrelpath(config.rootpath, config.inipath))
746746

747747
if config.args_source == Config.ArgsSource.TESTPATHS:
748748
testpaths: List[str] = config.getini("testpaths")
749-
line += ", testpaths: {}".format(", ".join(testpaths))
750-
751-
result = [line]
749+
result.append("testpaths: {}".format(", ".join(testpaths)))
752750

753751
plugininfo = config.pluginmanager.list_plugin_distinfo()
754752
if plugininfo:

testing/test_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_setupcfg_uses_toolpytest_with_pytest(self, pytester: Pytester) -> None:
7474
% p1.name,
7575
)
7676
result = pytester.runpytest()
77-
result.stdout.fnmatch_lines(["*, configfile: setup.cfg, *", "* 1 passed in *"])
77+
result.stdout.fnmatch_lines(["configfile: setup.cfg", "* 1 passed in *"])
7878
assert result.ret == 0
7979

8080
def test_append_parse_args(

testing/test_terminal.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ def test_header(self, pytester: Pytester) -> None:
909909
# with configfile
910910
pytester.makeini("""[pytest]""")
911911
result = pytester.runpytest()
912-
result.stdout.fnmatch_lines(["rootdir: *test_header0, configfile: tox.ini"])
912+
result.stdout.fnmatch_lines(["rootdir: *test_header0", "configfile: tox.ini"])
913913

914914
# with testpaths option, and not passing anything in the command-line
915915
pytester.makeini(
@@ -920,12 +920,12 @@ def test_header(self, pytester: Pytester) -> None:
920920
)
921921
result = pytester.runpytest()
922922
result.stdout.fnmatch_lines(
923-
["rootdir: *test_header0, configfile: tox.ini, testpaths: tests, gui"]
923+
["rootdir: *test_header0", "configfile: tox.ini", "testpaths: tests, gui"]
924924
)
925925

926926
# with testpaths option, passing directory in command-line: do not show testpaths then
927927
result = pytester.runpytest("tests")
928-
result.stdout.fnmatch_lines(["rootdir: *test_header0, configfile: tox.ini"])
928+
result.stdout.fnmatch_lines(["rootdir: *test_header0", "configfile: tox.ini"])
929929

930930
def test_header_absolute_testpath(
931931
self, pytester: Pytester, monkeypatch: MonkeyPatch
@@ -944,9 +944,9 @@ def test_header_absolute_testpath(
944944
result = pytester.runpytest()
945945
result.stdout.fnmatch_lines(
946946
[
947-
"rootdir: *absolute_testpath0, configfile: pyproject.toml, testpaths: {}".format(
948-
tests
949-
)
947+
"rootdir: *absolute_testpath0",
948+
"configfile: pyproject.toml",
949+
f"testpaths: {tests}",
950950
]
951951
)
952952

0 commit comments

Comments
 (0)