Merge pull request #4582 from jeffreyrack/4371-display-test-descriptions
4371: Update --collect-only to display test descriptions when ran in verbose
This commit is contained in:
commit
1a9979a803
|
@ -0,0 +1 @@
|
|||
Updated the ``--collect-only`` option to display test descriptions when ran using ``--verbose``.
|
|
@ -611,6 +611,10 @@ class TerminalReporter(object):
|
|||
continue
|
||||
indent = (len(stack) - 1) * " "
|
||||
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)
|
||||
def pytest_sessionfinish(self, exitstatus):
|
||||
|
|
|
@ -276,6 +276,18 @@ class TestCollectonly(object):
|
|||
result = testdir.runpytest("--collect-only", "-rs")
|
||||
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):
|
||||
testdir.makepyfile("""raise ValueError(0)""")
|
||||
result = testdir.runpytest("--collect-only")
|
||||
|
|
Loading…
Reference in New Issue