[py-svn] commit/pytest: RonnyPfannschmidt: add a reportchar for reporting errors, fixes #76

Bitbucket commits-noreply at bitbucket.org
Thu Sep 29 23:45:41 CEST 2011


1 new changeset in pytest:

http://bitbucket.org/hpk42/pytest/changeset/d2f6742b377c/
changeset:   d2f6742b377c
user:        RonnyPfannschmidt
date:        2011-09-29 23:44:26
summary:     add a reportchar for reporting errors, fixes #76
affected #:  3 files (-1 bytes)

--- a/_pytest/skipping.py	Sun Sep 25 23:26:49 2011 +0200
+++ b/_pytest/skipping.py	Thu Sep 29 23:44:26 2011 +0200
@@ -169,21 +169,23 @@
         elif char == "X":
             show_xpassed(terminalreporter, lines)
         elif char in "fF":
-            show_failed(terminalreporter, lines)
+            show_simple(terminalreporter, lines, 'failed', "FAIL %s")
         elif char in "sS":
             show_skipped(terminalreporter, lines)
+        elif char == "E":
+            show_simple(terminalreporter, lines, 'error', "ERROR %s")
     if lines:
         tr._tw.sep("=", "short test summary info")
         for line in lines:
             tr._tw.line(line)
 
-def show_failed(terminalreporter, lines):
+def show_simple(terminalreporter, lines, stat, format):
     tw = terminalreporter._tw
-    failed = terminalreporter.stats.get("failed")
+    failed = terminalreporter.stats.get(stat)
     if failed:
         for rep in failed:
             pos = rep.nodeid
-            lines.append("FAIL %s" %(pos, ))
+            lines.append(format %(pos, ))
 
 def show_xfailed(terminalreporter, lines):
     xfailed = terminalreporter.stats.get("xfailed")


--- a/_pytest/terminal.py	Sun Sep 25 23:26:49 2011 +0200
+++ b/_pytest/terminal.py	Thu Sep 29 23:44:26 2011 +0200
@@ -15,7 +15,7 @@
     group._addoption('-r',
          action="store", dest="reportchars", default=None, metavar="chars",
          help="show extra test summary info as specified by chars (f)ailed, "
-              "(s)skipped, (x)failed, (X)passed.")
+              "(E)error, (s)skipped, (x)failed, (X)passed.")
     group._addoption('-l', '--showlocals',
          action="store_true", dest="showlocals", default=False,
          help="show locals in tracebacks (disabled by default).")


--- a/testing/test_skipping.py	Sun Sep 25 23:26:49 2011 +0200
+++ b/testing/test_skipping.py	Thu Sep 29 23:44:26 2011 +0200
@@ -472,6 +472,21 @@
         "SKIP*four*",
     ])
 
+def test_reportchars_error(testdir):
+    testdir.makepyfile(
+        conftest="""
+        def pytest_runtest_teardown():
+            assert 0
+        """,
+        test_simple="""
+        def test_foo():
+            pass
+        """)
+    result = testdir.runpytest('-rE')
+    result.stdout.fnmatch_lines([
+        'ERROR*test_foo*',
+    ])
+
 @pytest.mark.xfail("hasattr(sys, 'pypy_version_info')")
 def test_errors_in_xfail_skip_expressions(testdir):
     testdir.makepyfile("""

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the pytest-commit mailing list