diff --git a/_pytest/main.py b/_pytest/main.py index 4ccdb38c4..3ebfc4dde 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -80,8 +80,9 @@ def wrap_session(config, doit): initstate = 2 doit(config, session) except pytest.UsageError: - msg = sys.exc_info()[1].args[0] - sys.stderr.write("ERROR: %s\n" %(msg,)) + args = sys.exc_info()[1].args + for msg in args: + sys.stderr.write("ERROR: %s\n" %(msg,)) session.exitstatus = EXIT_USAGEERROR except KeyboardInterrupt: excinfo = py.code.ExceptionInfo() @@ -538,9 +539,12 @@ class Session(FSCollector): self.ihook.pytest_collectreport(report=rep) self.trace.root.indent -= 1 if self._notfound: + errors = [] for arg, exc in self._notfound: 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: return rep.result else: @@ -561,8 +565,7 @@ class Session(FSCollector): # we are inside a make_report hook so # we cannot directly pass through the exception self._notfound.append((arg, sys.exc_info()[1])) - self.trace.root.indent -= 1 - break + self.trace.root.indent -= 1 def _collect(self, arg): diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 015e9e929..0cfe38e47 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -308,6 +308,14 @@ class TestGeneralUsage: ]) 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*", + ]) + def test_namespace_import_doesnt_confuse_import_hook(self, testdir): # Ref #383. Python 3.3's namespace package messed with our import hooks # Importing a module that didn't exist, even if the ImportError was