Merge pull request #5087 from samueljsb/issue/4907
Show XFail reason as part of JUnitXML message field
This commit is contained in:
commit
48ed437e70
1
AUTHORS
1
AUTHORS
|
@ -208,6 +208,7 @@ Ross Lawley
|
||||||
Russel Winder
|
Russel Winder
|
||||||
Ryan Wooden
|
Ryan Wooden
|
||||||
Samuel Dion-Girardeau
|
Samuel Dion-Girardeau
|
||||||
|
Samuel Searles-Bryant
|
||||||
Samuele Pedroni
|
Samuele Pedroni
|
||||||
Sankt Petersbug
|
Sankt Petersbug
|
||||||
Segev Finer
|
Segev Finer
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Show XFail reason as part of JUnitXML message field.
|
|
@ -252,7 +252,14 @@ class _NodeReporter(object):
|
||||||
|
|
||||||
def append_skipped(self, report):
|
def append_skipped(self, report):
|
||||||
if hasattr(report, "wasxfail"):
|
if hasattr(report, "wasxfail"):
|
||||||
self._add_simple(Junit.skipped, "expected test failure", report.wasxfail)
|
xfailreason = report.wasxfail
|
||||||
|
if xfailreason.startswith("reason: "):
|
||||||
|
xfailreason = xfailreason[8:]
|
||||||
|
self.append(
|
||||||
|
Junit.skipped(
|
||||||
|
"", type="pytest.xfail", message=bin_xml_escape(xfailreason)
|
||||||
|
)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
filename, lineno, skipreason = report.longrepr
|
filename, lineno, skipreason = report.longrepr
|
||||||
if skipreason.startswith("Skipped: "):
|
if skipreason.startswith("Skipped: "):
|
||||||
|
|
|
@ -485,9 +485,27 @@ class TestPython(object):
|
||||||
tnode = node.find_first_by_tag("testcase")
|
tnode = node.find_first_by_tag("testcase")
|
||||||
tnode.assert_attr(classname="test_xfailure_function", name="test_xfail")
|
tnode.assert_attr(classname="test_xfailure_function", name="test_xfail")
|
||||||
fnode = tnode.find_first_by_tag("skipped")
|
fnode = tnode.find_first_by_tag("skipped")
|
||||||
fnode.assert_attr(message="expected test failure")
|
fnode.assert_attr(type="pytest.xfail", message="42")
|
||||||
# assert "ValueError" in fnode.toxml()
|
# assert "ValueError" in fnode.toxml()
|
||||||
|
|
||||||
|
def test_xfailure_marker(self, testdir):
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
import pytest
|
||||||
|
@pytest.mark.xfail(reason="42")
|
||||||
|
def test_xfail():
|
||||||
|
assert False
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result, dom = runandparse(testdir)
|
||||||
|
assert not result.ret
|
||||||
|
node = dom.find_first_by_tag("testsuite")
|
||||||
|
node.assert_attr(skipped=1, tests=1)
|
||||||
|
tnode = node.find_first_by_tag("testcase")
|
||||||
|
tnode.assert_attr(classname="test_xfailure_marker", name="test_xfail")
|
||||||
|
fnode = tnode.find_first_by_tag("skipped")
|
||||||
|
fnode.assert_attr(type="pytest.xfail", message="42")
|
||||||
|
|
||||||
def test_xfail_captures_output_once(self, testdir):
|
def test_xfail_captures_output_once(self, testdir):
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue