diff --git a/changelog/4875.feature.rst b/changelog/4875.feature.rst new file mode 100644 index 000000000..6d91fb465 --- /dev/null +++ b/changelog/4875.feature.rst @@ -0,0 +1,3 @@ +The `testpaths `__ configuration option is now displayed next +to the ``rootdir`` and ``inifile`` lines in the pytest header if the option is in effect, i.e., directories or file names were +not explicitly passed in the command line. diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index eda0c0905..fc78f4de4 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -586,8 +586,13 @@ class TerminalReporter(object): inifile = "" if config.inifile: inifile = " " + config.rootdir.bestrelpath(config.inifile) - lines = ["rootdir: %s, inifile:%s" % (config.rootdir, inifile)] + line = "rootdir: %s, inifile:%s" % (config.rootdir, inifile) + testpaths = config.getini("testpaths") + if testpaths and config.args == testpaths: + rel_paths = [config.rootdir.bestrelpath(x) for x in testpaths] + line += ", testpaths: {}".format(", ".join(rel_paths)) + lines = [line] plugininfo = config.pluginmanager.list_plugin_distinfo() if plugininfo: diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 798e8c16a..abe9549e2 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -567,6 +567,26 @@ class TestTerminalFunctional(object): if request.config.pluginmanager.list_plugin_distinfo(): result.stdout.fnmatch_lines(["plugins: *"]) + def test_header(self, testdir, request): + testdir.tmpdir.join("tests").ensure_dir() + testdir.tmpdir.join("gui").ensure_dir() + result = testdir.runpytest() + result.stdout.fnmatch_lines(["rootdir: *test_header0, inifile:"]) + + testdir.makeini( + """ + [pytest] + testpaths = tests gui + """ + ) + result = testdir.runpytest() + result.stdout.fnmatch_lines( + ["rootdir: *test_header0, inifile: tox.ini, testpaths: tests, gui"] + ) + + result = testdir.runpytest("tests") + result.stdout.fnmatch_lines(["rootdir: *test_header0, inifile: tox.ini"]) + def test_showlocals(self, testdir): p1 = testdir.makepyfile( """