Show testpaths option in the header if it has been used for collection
Fix #4875
This commit is contained in:
parent
e1f97e41e3
commit
53b8aa065c
|
@ -0,0 +1,3 @@
|
||||||
|
The `testpaths <https://docs.pytest.org/en/latest/reference.html#confval-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.
|
|
@ -586,8 +586,13 @@ class TerminalReporter(object):
|
||||||
inifile = ""
|
inifile = ""
|
||||||
if config.inifile:
|
if config.inifile:
|
||||||
inifile = " " + config.rootdir.bestrelpath(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()
|
plugininfo = config.pluginmanager.list_plugin_distinfo()
|
||||||
if plugininfo:
|
if plugininfo:
|
||||||
|
|
||||||
|
|
|
@ -567,6 +567,26 @@ class TestTerminalFunctional(object):
|
||||||
if request.config.pluginmanager.list_plugin_distinfo():
|
if request.config.pluginmanager.list_plugin_distinfo():
|
||||||
result.stdout.fnmatch_lines(["plugins: *"])
|
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):
|
def test_showlocals(self, testdir):
|
||||||
p1 = testdir.makepyfile(
|
p1 = testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue