output errors for all failures of specific collection
when issueing a command with many specific items to collect, print all collect failures instead of just the first one --HG-- branch : multi-usageerror
This commit is contained in:
parent
f7f569f730
commit
cf37c477bb
|
@ -82,8 +82,9 @@ def wrap_session(config, doit):
|
||||||
initstate = 2
|
initstate = 2
|
||||||
doit(config, session)
|
doit(config, session)
|
||||||
except pytest.UsageError:
|
except pytest.UsageError:
|
||||||
msg = sys.exc_info()[1].args[0]
|
args = sys.exc_info()[1].args
|
||||||
sys.stderr.write("ERROR: %s\n" %(msg,))
|
for msg in args:
|
||||||
|
sys.stderr.write("ERROR: %s\n" %(msg,))
|
||||||
session.exitstatus = EXIT_USAGEERROR
|
session.exitstatus = EXIT_USAGEERROR
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
excinfo = py.code.ExceptionInfo()
|
excinfo = py.code.ExceptionInfo()
|
||||||
|
@ -516,9 +517,12 @@ class Session(FSCollector):
|
||||||
self.ihook.pytest_collectreport(report=rep)
|
self.ihook.pytest_collectreport(report=rep)
|
||||||
self.trace.root.indent -= 1
|
self.trace.root.indent -= 1
|
||||||
if self._notfound:
|
if self._notfound:
|
||||||
|
errors = []
|
||||||
for arg, exc in self._notfound:
|
for arg, exc in self._notfound:
|
||||||
line = "(no name %r in any of %r)" % (arg, exc.args[0])
|
line = "(no name %r in any of %r)" % (arg, exc.args[0])
|
||||||
raise pytest.UsageError("not found: %s\n%s" %(arg, line))
|
errors.append("not found: %s\n%s" % (arg, line))
|
||||||
|
#XXX: test this
|
||||||
|
raise pytest.UsageError(*errors)
|
||||||
if not genitems:
|
if not genitems:
|
||||||
return rep.result
|
return rep.result
|
||||||
else:
|
else:
|
||||||
|
@ -539,8 +543,7 @@ class Session(FSCollector):
|
||||||
# we are inside a make_report hook so
|
# we are inside a make_report hook so
|
||||||
# we cannot directly pass through the exception
|
# we cannot directly pass through the exception
|
||||||
self._notfound.append((arg, sys.exc_info()[1]))
|
self._notfound.append((arg, sys.exc_info()[1]))
|
||||||
self.trace.root.indent -= 1
|
|
||||||
break
|
|
||||||
self.trace.root.indent -= 1
|
self.trace.root.indent -= 1
|
||||||
|
|
||||||
def _collect(self, arg):
|
def _collect(self, arg):
|
||||||
|
|
|
@ -308,6 +308,14 @@ class TestGeneralUsage:
|
||||||
])
|
])
|
||||||
assert result.ret == 4 # usage error only if item not found
|
assert result.ret == 4 # usage error only if item not found
|
||||||
|
|
||||||
|
def test_report_all_failed_collections_initargs(self, testdir):
|
||||||
|
testdir.makepyfile(test_a="def", test_b="def")
|
||||||
|
result = testdir.runpytest("test_a.py::a", "test_b.py::b")
|
||||||
|
result.stderr.fnmatch_lines([
|
||||||
|
"*ERROR*test_a.py::a*",
|
||||||
|
"*ERROR*test_b.py::b*",
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
class TestInvocationVariants:
|
class TestInvocationVariants:
|
||||||
def test_earlyinit(self, testdir):
|
def test_earlyinit(self, testdir):
|
||||||
|
|
Loading…
Reference in New Issue