backport fix for #713

This commit is contained in:
Punyashloka Biswal 2015-06-16 16:35:31 -04:00 committed by Bruno Oliveira
parent f04e01f55f
commit 0c05b906d4
4 changed files with 24 additions and 2 deletions

View File

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

View File

@ -1,6 +1,9 @@
2.7.2 (compared to 2.7.1)
-----------------------------
- fix issue713: JUnit XML reports for doctest failures.
Thanks Punyashloka Biswal.
- fix issue735: assertion failures on debug versions of Python 3.4+
Thanks Benjamin Peterson.

View File

@ -123,10 +123,12 @@ class LogXML(object):
Junit.skipped(message="xfail-marked test passes unexpectedly"))
self.skipped += 1
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
else:
message = report.longrepr.reprcrash.message
message = str(report.longrepr)
message = bin_xml_escape(message)
fail = Junit.failure(message=message)
fail.append(bin_xml_escape(report.longrepr))

View File

@ -354,3 +354,19 @@ class TestDoctests:
reprec = testdir.inline_run(p, "--doctest-modules",
"--doctest-ignore-import-errors")
reprec.assertoutcome(skipped=1, failed=1, passed=0)
def test_junit_report_for_doctest(self, testdir):
"""
#713: Fix --junit-xml option when used with --doctest-modules.
"""
p = testdir.makepyfile("""
def foo():
'''
>>> 1 + 1
3
'''
pass
""")
reprec = testdir.inline_run(p, "--doctest-modules",
"--junit-xml=junit.xml")
reprec.assertoutcome(failed=1)