fix issue134 - print the collect errors that prevent running specified test items
This commit is contained in:
parent
ca8b3c2307
commit
69ef750091
|
@ -331,7 +331,7 @@ class TerminalReporter:
|
||||||
def pytest_sessionfinish(self, exitstatus, __multicall__):
|
def pytest_sessionfinish(self, exitstatus, __multicall__):
|
||||||
__multicall__.execute()
|
__multicall__.execute()
|
||||||
self._tw.line("")
|
self._tw.line("")
|
||||||
if exitstatus in (0, 1, 2):
|
if exitstatus in (0, 1, 2, 4):
|
||||||
self.summary_errors()
|
self.summary_errors()
|
||||||
self.summary_failures()
|
self.summary_failures()
|
||||||
self.config.hook.pytest_terminal_summary(terminalreporter=self)
|
self.config.hook.pytest_terminal_summary(terminalreporter=self)
|
||||||
|
|
|
@ -294,6 +294,21 @@ class TestGeneralUsage:
|
||||||
])
|
])
|
||||||
assert 'sessionstarttime' not in result.stderr.str()
|
assert 'sessionstarttime' not in result.stderr.str()
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('lookfor', ['test_fun.py', 'test_fun.py::test_a'])
|
||||||
|
def test_issue134_report_syntaxerror_when_collecting_member(self, testdir, lookfor):
|
||||||
|
testdir.makepyfile(test_fun="""
|
||||||
|
def test_a():
|
||||||
|
pass
|
||||||
|
def""")
|
||||||
|
result = testdir.runpytest(lookfor)
|
||||||
|
result.stdout.fnmatch_lines(['*SyntaxError*'])
|
||||||
|
if '::' in lookfor:
|
||||||
|
result.stderr.fnmatch_lines([
|
||||||
|
'*ERROR*',
|
||||||
|
])
|
||||||
|
assert result.ret == 4 # usage error only if item not found
|
||||||
|
|
||||||
|
|
||||||
class TestInvocationVariants:
|
class TestInvocationVariants:
|
||||||
def test_earlyinit(self, testdir):
|
def test_earlyinit(self, testdir):
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
|
|
Loading…
Reference in New Issue