fix issue380 by making --resultlog only rely on longrepr instead

of the "reprcrash" attribute which only exists sometimes.
This commit is contained in:
holger krekel 2013-11-19 14:19:29 +01:00
parent 82846777a7
commit 31576fac61
3 changed files with 25 additions and 2 deletions

View File

@ -5,6 +5,9 @@ Unreleased
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)

View File

@ -6,7 +6,7 @@ import py
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 @@ class ResultLog(object):
if not report.passed:
if report.failed:
code = "F"
longrepr = str(report.longrepr.reprcrash)
longrepr = str(report.longrepr)
else:
assert report.skipped
code = "S"

View File

@ -195,3 +195,23 @@ def test_no_resultlog_on_slaves(testdir):
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