fix issue134 - print the collect errors that prevent running specified test items

This commit is contained in:
Ronny Pfannschmidt 2013-02-14 12:21:42 +01:00
parent ca8b3c2307
commit 69ef750091
2 changed files with 16 additions and 1 deletions

View File

@ -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)

View File

@ -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("""