diff --git a/changelog/10727.improvement.rst b/changelog/10727.improvement.rst new file mode 100644 index 000000000..92cb8cc33 --- /dev/null +++ b/changelog/10727.improvement.rst @@ -0,0 +1 @@ +Split the report header for ``rootdir``, ``config file`` and ``testpaths`` so each has its own line. diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 323c118e4..dfc0fa98e 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -739,16 +739,14 @@ class TerminalReporter: self.write_line(line) def pytest_report_header(self, config: Config) -> List[str]: - line = "rootdir: %s" % config.rootpath + result = [f"rootdir: {config.rootpath}"] if config.inipath: - line += ", configfile: " + bestrelpath(config.rootpath, config.inipath) + result.append("configfile: " + bestrelpath(config.rootpath, config.inipath)) if config.args_source == Config.ArgsSource.TESTPATHS: testpaths: List[str] = config.getini("testpaths") - line += ", testpaths: {}".format(", ".join(testpaths)) - - result = [line] + result.append("testpaths: {}".format(", ".join(testpaths))) plugininfo = config.pluginmanager.list_plugin_distinfo() if plugininfo: diff --git a/testing/test_config.py b/testing/test_config.py index 35e2a601c..6754cd15b 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -74,7 +74,7 @@ class TestParseIni: % p1.name, ) result = pytester.runpytest() - result.stdout.fnmatch_lines(["*, configfile: setup.cfg, *", "* 1 passed in *"]) + result.stdout.fnmatch_lines(["configfile: setup.cfg", "* 1 passed in *"]) assert result.ret == 0 def test_append_parse_args( diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 8a77e107d..fe325b72d 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -909,7 +909,7 @@ class TestTerminalFunctional: # with configfile pytester.makeini("""[pytest]""") result = pytester.runpytest() - result.stdout.fnmatch_lines(["rootdir: *test_header0, configfile: tox.ini"]) + result.stdout.fnmatch_lines(["rootdir: *test_header0", "configfile: tox.ini"]) # with testpaths option, and not passing anything in the command-line pytester.makeini( @@ -920,12 +920,12 @@ class TestTerminalFunctional: ) result = pytester.runpytest() result.stdout.fnmatch_lines( - ["rootdir: *test_header0, configfile: tox.ini, testpaths: tests, gui"] + ["rootdir: *test_header0", "configfile: tox.ini", "testpaths: tests, gui"] ) # with testpaths option, passing directory in command-line: do not show testpaths then result = pytester.runpytest("tests") - result.stdout.fnmatch_lines(["rootdir: *test_header0, configfile: tox.ini"]) + result.stdout.fnmatch_lines(["rootdir: *test_header0", "configfile: tox.ini"]) def test_header_absolute_testpath( self, pytester: Pytester, monkeypatch: MonkeyPatch @@ -944,9 +944,9 @@ class TestTerminalFunctional: result = pytester.runpytest() result.stdout.fnmatch_lines( [ - "rootdir: *absolute_testpath0, configfile: pyproject.toml, testpaths: {}".format( - tests - ) + "rootdir: *absolute_testpath0", + "configfile: pyproject.toml", + f"testpaths: {tests}", ] )