Commits

Ronny Pfannschmidt committed b1558ab

lotsa patches

  • Participants
  • Parent commits 0dc5c09

Comments (0)

Files changed (8)

File exitstatus-usageerror

+# HG changeset patch
+# Parent ae549ef60e51bdc12075a66af6ebedab85bce067
+diff --git a/_pytest/terminal.py b/_pytest/terminal.py
+--- a/_pytest/terminal.py
++++ b/_pytest/terminal.py
+@@ -331,7 +331,7 @@ class TerminalReporter:
+     def pytest_sessionfinish(self, exitstatus, __multicall__):
+         __multicall__.execute()
+         self._tw.line("")
+-        if exitstatus in (0, 1, 2):
++        if exitstatus in (0, 1, 2, 4):
+             self.summary_errors()
+             self.summary_failures()
+             self.config.hook.pytest_terminal_summary(terminalreporter=self)

File handle-usageerror

 # HG changeset patch
-# Parent 4d4ce0192c296472a9cd0ad513d81950e4cc9502
-diff --git a/_pytest/main.py b/_pytest/main.py
---- a/_pytest/main.py
-+++ b/_pytest/main.py
-@@ -64,6 +64,7 @@ def wrap_session(config, doit):
-     session = Session(config)
-     session.exitstatus = EXIT_OK
-     initstate = 0
-+    reraise = None
-     try:
-         config.pluginmanager.do_configure(config)
-         initstate = 1
-@@ -71,7 +72,7 @@ def wrap_session(config, doit):
-         initstate = 2
-         doit(config, session)
-     except pytest.UsageError:
--        raise
-+        reraise = sys.exc_info()
-     except KeyboardInterrupt:
-         excinfo = py.code.ExceptionInfo()
-         config.hook.pytest_keyboard_interrupt(excinfo=excinfo)
-@@ -89,6 +90,8 @@ def wrap_session(config, doit):
-         session.exitstatus = EXIT_TESTSFAILED
-     if initstate >= 1:
-         config.pluginmanager.do_unconfigure(config)
-+    if reraise:
-+        py.builtin._reraise(*reraise)
-     return session.exitstatus
- 
- def pytest_cmdline_main(config):
+# Parent 1677d28d838388ff579e953b523f47cf6c83ed20
+
 diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py
 --- a/testing/acceptance_test.py
 +++ b/testing/acceptance_test.py
-@@ -278,6 +278,15 @@ class TestGeneralUsage:
+@@ -294,6 +294,15 @@ class TestGeneralUsage:
          ])
          assert 'sessionstarttime' not in result.stderr.str()
  
 # HG changeset patch
-# Parent a5e7a5fa3c7e8aef9306f60c9e0d42c01e4252c7
+# Parent 1677d28d838388ff579e953b523f47cf6c83ed20
+
 diff --git a/testing/test_mark.py b/testing/test_mark.py
 --- a/testing/test_mark.py
 +++ b/testing/test_mark.py
  
  class TestMark:
      def test_markinfo_repr(self):
-@@ -138,6 +138,21 @@ def test_mark_option(spec, testdir):
+@@ -180,6 +180,21 @@ def test_keyword_option_custom(spec, tes
+     assert len(passed) == len(passed_result)
      assert list(passed) == list(passed_result)
  
- 
 +class TestMarkMatching:
 +    def test_normal_item(self, testdir):
 +        items = testdir.getitems("""

File multi-usageerror

+# HG changeset patch
+# Parent 7f78901f2ea0f5b3cd8e7850eee39f7a98f53f95
+diff --git a/_pytest/main.py b/_pytest/main.py
+--- 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()
+@@ -490,9 +491,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:
+diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py
+--- 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")
++        assert result.stderr.fnmatch_lines([
++            "*ERROR*ADV",
++            "*ERROR*ABC",
++        ])
++
+ 
+ class TestInvocationVariants:
+     def test_earlyinit(self, testdir):

File nicer-exitstatus-usageerror

+# HG changeset patch
+# Parent 23272af1ede83c4368c6cbc59b035e8bd7953244
+diff --git a/_pytest/main.py b/_pytest/main.py
+--- a/_pytest/main.py
++++ b/_pytest/main.py
+@@ -93,10 +93,13 @@ def wrap_session(config, doit):
+             session.exitstatus = EXIT_INTERNALERROR
+             if excinfo.errisinstance(SystemExit):
+                 sys.stderr.write("mainloop: caught Spurious SystemExit!\n")
++        else:
++            if session._testsfailed:
++                session.exitstatus = EXIT_TESTSFAILED
+     finally:
+         if initstate >= 2:
+             config.hook.pytest_sessionfinish(session=session,
+-                exitstatus=session.exitstatus or (session._testsfailed and 1))
++                exitstatus=session.exitstatus)
+         if not session.exitstatus and session._testsfailed:
+             session.exitstatus = EXIT_TESTSFAILED
+         if initstate >= 1:

File parametrize

-# HG changeset patch
-# Parent 79a5b776a6f3f34f8699e130cfe5440b1ff67336
-diff --git a/doc/example/parametrize.txt b/doc/example/parametrize.txt
---- a/doc/example/parametrize.txt
-+++ b/doc/example/parametrize.txt
-@@ -326,3 +326,19 @@ Running it results in some skips if we d
-    ========================= short test summary info ==========================
-    SKIP [27] /home/hpk/p/pytest/doc/example/multipython.py:36: 'python2.8' not found
-    48 passed, 27 skipped in 1.71 seconds
-+
-+
-+
-+Extended Parameter configuration
-+--------------------------------
-+
-+
-+::
-+    def pytest_generate_test(metafunc):
-+        marks = [pytest.mark.xfail_if('"__pypy__" in sys.modules')
-+
-+        metafunc.combine_calls('type_',[
-+            ('number', int, marks),
-+            ('string', str, marks),
-+            ('mapping, dict, marks),
-+        ])
-unittest-allmodules
-issue187
-parametrize
+unittest-allmodules #+unittest
+issue187 #+marks
 handle-usageerror
+nicer-exitstatus-usageerror
+exitstatus-usageerror
+test_collect_syntaxerror
+multi-usageerror
 asser-reloader-package
 junitxml-partial-writing
 regendoc-pytesthighlight

File test_collect_syntaxerror

+# HG changeset patch
+# Parent 38591ce4072b280d35c62c449ce6b70892c66dcd
+diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py
+--- a/testing/acceptance_test.py
++++ b/testing/acceptance_test.py
+@@ -294,13 +294,19 @@ class TestGeneralUsage:
+         ])
+         assert 'sessionstarttime' not in result.stderr.str()
+ 
+-    def test_issue134_report_syntaxerror_when_collecting_member(self,testdir):
++    @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('test_fun.py::test_a')
++        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: