Handle reports that don't have a reprcrash

Closes #713 (which happens because ReprFailDoctest
doesn't have a reprcrash)
This commit is contained in:
Punyashloka Biswal 2015-06-16 16:35:31 -04:00 committed by Punya Biswal
parent f1245b094f
commit 0b0406fa85
4 changed files with 21 additions and 2 deletions

View File

@ -43,6 +43,7 @@ Mark Abramowitz
Martijn Faassen Martijn Faassen
Nicolas Delaby Nicolas Delaby
Piotr Banaszkiewicz Piotr Banaszkiewicz
Punyashloka Biswal
Ralf Schmitt Ralf Schmitt
Ronny Pfannschmidt Ronny Pfannschmidt
Ross Lawley Ross Lawley

View File

@ -1,6 +1,9 @@
2.8.0.dev (compared to 2.7.X) 2.8.0.dev (compared to 2.7.X)
----------------------------- -----------------------------
- fix issue713: JUnit XML reports for doctest failures.
Thanks Punyashloka Biswal.
- Include setup and teardown in junitxml test durations. - Include setup and teardown in junitxml test durations.
Thanks Janne Vanhala. Thanks Janne Vanhala.

View File

@ -123,10 +123,12 @@ class LogXML(object):
Junit.skipped(message="xfail-marked test passes unexpectedly")) Junit.skipped(message="xfail-marked test passes unexpectedly"))
self.skipped += 1 self.skipped += 1
else: else:
if isinstance(report.longrepr, (unicode, str)): if hasattr(report.longrepr, "reprcrash"):
message = report.longrepr.reprcrash.message
elif isinstance(report.longrepr, (unicode, str)):
message = report.longrepr message = report.longrepr
else: else:
message = report.longrepr.reprcrash.message message = str(report.longrepr)
message = bin_xml_escape(message) message = bin_xml_escape(message)
fail = Junit.failure(message=message) fail = Junit.failure(message=message)
fail.append(bin_xml_escape(report.longrepr)) fail.append(bin_xml_escape(report.longrepr))

View File

@ -352,3 +352,16 @@ class TestDoctests:
reprec = testdir.inline_run(p, "--doctest-modules", reprec = testdir.inline_run(p, "--doctest-modules",
"--doctest-ignore-import-errors") "--doctest-ignore-import-errors")
reprec.assertoutcome(skipped=1, failed=1, passed=0) reprec.assertoutcome(skipped=1, failed=1, passed=0)
def test_junit_report_for_doctest(self, testdir):
p = testdir.makepyfile("""
def foo():
'''
>>> 1 + 1
3
'''
pass
""")
reprec = testdir.inline_run(p, "--doctest-modules",
"--junit-xml=junit.xml")
reprec.assertoutcome(failed=1)