Commits

Ronny Pfannschmidt committed fa8f769

test for usage error stuff

  • Participants
  • Parent commits 8eb13a6

Comments (0)

Files changed (3)

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):
+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:
+         ])
+         assert 'sessionstarttime' not in result.stderr.str()
+ 
++    def test_issue134_report_syntaxerror_when_collecting_member(self,testdir):
++        testdir.makepyfile(test_fun="""
++            def test_a():
++                pass
++            def""")
++        result = testdir.runpytest('test_fun.py::test_a')
++        result.stdout.fnmatch_lines(['*SyntaxError*'])
++
++
+ class TestInvocationVariants:
+     def test_earlyinit(self, testdir):
+         p = testdir.makepyfile("""

File junitxml-partial-writing

+# HG changeset patch
+# Parent 6c209f9cfe007a7730a39dd3f3e73babba42e553
+handle-usageerror
+junitxml-partial-writing
 parametrize-items
 regendoc-pytesthighlight #+doc
 fnmatch-python-test-names