[Pytest-commit] commit/pytest: hpk42: fix issue380 by making --resultlog only rely on longrepr instead

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Nov 19 14:19:37 CET 2013


1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/b1bd58344edd/
Changeset:   b1bd58344edd
User:        hpk42
Date:        2013-11-19 14:19:29
Summary:     fix issue380 by making --resultlog only rely on longrepr instead
of the "reprcrash" attribute which only exists sometimes.
Affected #:  3 files

diff -r 20a35e86eff1895b8eaade96dd6ebb58814d3c8a -r b1bd58344eddcb775617b83e87a74333a1febe84 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,9 @@
   since the unittest compat enhancements allow
   trial to handle it on its own
 
+- fix issue380 by making --resultlog only rely on longrepr instead
+  of the "reprcrash" attribute which only exists sometimes.
+
 - fix pexpect-3.0 compatibility for pytest's own tests.
   (fixes issue386)
 

diff -r 20a35e86eff1895b8eaade96dd6ebb58814d3c8a -r b1bd58344eddcb775617b83e87a74333a1febe84 _pytest/resultlog.py
--- a/_pytest/resultlog.py
+++ b/_pytest/resultlog.py
@@ -6,7 +6,7 @@
 
 def pytest_addoption(parser):
     group = parser.getgroup("terminal reporting", "resultlog plugin options")
-    group.addoption('--resultlog', '--result-log', action="store", 
+    group.addoption('--resultlog', '--result-log', action="store",
         metavar="path", default=None,
         help="path for machine-readable result log.")
 
@@ -85,7 +85,7 @@
         if not report.passed:
             if report.failed:
                 code = "F"
-                longrepr = str(report.longrepr.reprcrash)
+                longrepr = str(report.longrepr)
             else:
                 assert report.skipped
                 code = "S"

diff -r 20a35e86eff1895b8eaade96dd6ebb58814d3c8a -r b1bd58344eddcb775617b83e87a74333a1febe84 testing/test_resultlog.py
--- a/testing/test_resultlog.py
+++ b/testing/test_resultlog.py
@@ -195,3 +195,23 @@
     pytest_unconfigure(config)
     assert not hasattr(config, '_resultlog')
 
+
+def test_failure_issue380(testdir):
+    testdir.makeconftest("""
+        import pytest
+        class MyCollector(pytest.File):
+            def collect(self):
+                raise ValueError()
+            def repr_failure(self, excinfo):
+                return "somestring"
+        def pytest_collect_file(path, parent):
+            return MyCollector(parent=parent, fspath=path)
+    """)
+    testdir.makepyfile("""
+        def test_func():
+            pass
+    """)
+    result = testdir.runpytest("--resultlog=log")
+    assert result.ret == 1
+
+

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