Failure message in junit xml report now are more informative
--HG-- branch : junit-verbose-failures
This commit is contained in:
parent
3df5989326
commit
9f4d0be895
|
@ -123,7 +123,12 @@ class LogXML(object):
|
|||
Junit.skipped(message="xfail-marked test passes unexpectedly"))
|
||||
self.skipped += 1
|
||||
else:
|
||||
fail = Junit.failure(message="test failure")
|
||||
if isinstance(report.longrepr, (unicode, str)):
|
||||
message = report.longrepr
|
||||
else:
|
||||
message = report.longrepr.reprcrash.message
|
||||
message = bin_xml_escape(message)
|
||||
fail = Junit.failure(message=message)
|
||||
fail.append(bin_xml_escape(report.longrepr))
|
||||
self.append(fail)
|
||||
self.failed += 1
|
||||
|
|
|
@ -150,7 +150,7 @@ class TestPython:
|
|||
classname="test_failure_function",
|
||||
name="test_fail")
|
||||
fnode = tnode.getElementsByTagName("failure")[0]
|
||||
assert_attr(fnode, message="test failure")
|
||||
assert_attr(fnode, message="ValueError: 42")
|
||||
assert "ValueError" in fnode.toxml()
|
||||
systemout = fnode.nextSibling
|
||||
assert systemout.tagName == "system-out"
|
||||
|
@ -159,6 +159,19 @@ class TestPython:
|
|||
assert systemerr.tagName == "system-err"
|
||||
assert "hello-stderr" in systemerr.toxml()
|
||||
|
||||
def test_failure_verbose_message(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import sys
|
||||
def test_fail():
|
||||
assert 0, "An error"
|
||||
""")
|
||||
|
||||
result, dom = runandparse(testdir)
|
||||
node = dom.getElementsByTagName("testsuite")[0]
|
||||
tnode = node.getElementsByTagName("testcase")[0]
|
||||
fnode = tnode.getElementsByTagName("failure")[0]
|
||||
assert_attr(fnode, message="AssertionError: An error assert 0")
|
||||
|
||||
def test_failure_escape(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
|
@ -371,7 +384,7 @@ class TestNonPython:
|
|||
#classname="test_collect_error",
|
||||
name="myfile.xyz")
|
||||
fnode = tnode.getElementsByTagName("failure")[0]
|
||||
assert_attr(fnode, message="test failure")
|
||||
assert_attr(fnode, message="custom item runtest failed")
|
||||
assert "custom item runtest failed" in fnode.toxml()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue