Update --collect-only to display test descriptions when ran in verbose mode.
This commit is contained in:
parent
134ace98d9
commit
1eef53b6fe
|
@ -0,0 +1 @@
|
||||||
|
Updated the ``--collect-only`` option to display test descriptions when ran using ``--verbose``.
|
|
@ -611,6 +611,10 @@ class TerminalReporter(object):
|
||||||
continue
|
continue
|
||||||
indent = (len(stack) - 1) * " "
|
indent = (len(stack) - 1) * " "
|
||||||
self._tw.line("%s%s" % (indent, col))
|
self._tw.line("%s%s" % (indent, col))
|
||||||
|
if self.config.option.verbose >= 1:
|
||||||
|
if hasattr(col, "_obj") and col._obj.__doc__:
|
||||||
|
for line in col._obj.__doc__.strip().splitlines():
|
||||||
|
self._tw.line("%s%s" % (indent + " ", line.strip()))
|
||||||
|
|
||||||
@pytest.hookimpl(hookwrapper=True)
|
@pytest.hookimpl(hookwrapper=True)
|
||||||
def pytest_sessionfinish(self, exitstatus):
|
def pytest_sessionfinish(self, exitstatus):
|
||||||
|
|
|
@ -276,6 +276,18 @@ class TestCollectonly(object):
|
||||||
result = testdir.runpytest("--collect-only", "-rs")
|
result = testdir.runpytest("--collect-only", "-rs")
|
||||||
result.stdout.fnmatch_lines(["*ERROR collecting*"])
|
result.stdout.fnmatch_lines(["*ERROR collecting*"])
|
||||||
|
|
||||||
|
def test_collectonly_display_test_description(self, testdir):
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
def test_with_description():
|
||||||
|
\""" This test has a description.
|
||||||
|
\"""
|
||||||
|
assert True
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = testdir.runpytest("--collect-only", "--verbose")
|
||||||
|
result.stdout.fnmatch_lines([" This test has a description."])
|
||||||
|
|
||||||
def test_collectonly_failed_module(self, testdir):
|
def test_collectonly_failed_module(self, testdir):
|
||||||
testdir.makepyfile("""raise ValueError(0)""")
|
testdir.makepyfile("""raise ValueError(0)""")
|
||||||
result = testdir.runpytest("--collect-only")
|
result = testdir.runpytest("--collect-only")
|
||||||
|
|
Loading…
Reference in New Issue