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
This commit is contained in:
Ronny Pfannschmidt 2023-02-12 09:46:07 +01:00
parent 431ec6d34e
commit 407b330fe1
4 changed files with 11 additions and 12 deletions

View File

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

View File

@ -739,16 +739,14 @@ class TerminalReporter:
self.write_line(line) self.write_line(line)
def pytest_report_header(self, config: Config) -> List[str]: def pytest_report_header(self, config: Config) -> List[str]:
line = "rootdir: %s" % config.rootpath result = [f"rootdir: {config.rootpath}"]
if config.inipath: 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: if config.args_source == Config.ArgsSource.TESTPATHS:
testpaths: List[str] = config.getini("testpaths") testpaths: List[str] = config.getini("testpaths")
line += ", testpaths: {}".format(", ".join(testpaths)) result.append("testpaths: {}".format(", ".join(testpaths)))
result = [line]
plugininfo = config.pluginmanager.list_plugin_distinfo() plugininfo = config.pluginmanager.list_plugin_distinfo()
if plugininfo: if plugininfo:

View File

@ -74,7 +74,7 @@ class TestParseIni:
% p1.name, % p1.name,
) )
result = pytester.runpytest() 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 assert result.ret == 0
def test_append_parse_args( def test_append_parse_args(

View File

@ -909,7 +909,7 @@ class TestTerminalFunctional:
# with configfile # with configfile
pytester.makeini("""[pytest]""") pytester.makeini("""[pytest]""")
result = pytester.runpytest() 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 # with testpaths option, and not passing anything in the command-line
pytester.makeini( pytester.makeini(
@ -920,12 +920,12 @@ class TestTerminalFunctional:
) )
result = pytester.runpytest() result = pytester.runpytest()
result.stdout.fnmatch_lines( 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 # with testpaths option, passing directory in command-line: do not show testpaths then
result = pytester.runpytest("tests") 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( def test_header_absolute_testpath(
self, pytester: Pytester, monkeypatch: MonkeyPatch self, pytester: Pytester, monkeypatch: MonkeyPatch
@ -944,9 +944,9 @@ class TestTerminalFunctional:
result = pytester.runpytest() result = pytester.runpytest()
result.stdout.fnmatch_lines( result.stdout.fnmatch_lines(
[ [
"rootdir: *absolute_testpath0, configfile: pyproject.toml, testpaths: {}".format( "rootdir: *absolute_testpath0",
tests "configfile: pyproject.toml",
) f"testpaths: {tests}",
] ]
) )