Merge pull request #4167 from vbarbaresi/3533_junit_escape_skipped
Fix #3533: properly escape raw XML object
This commit is contained in:
commit
f858177495
|
@ -0,0 +1 @@
|
||||||
|
Fix unescaped XML raw objects in JUnit report for skipped tests
|
|
@ -221,12 +221,14 @@ class _NodeReporter(object):
|
||||||
else:
|
else:
|
||||||
filename, lineno, skipreason = report.longrepr
|
filename, lineno, skipreason = report.longrepr
|
||||||
if skipreason.startswith("Skipped: "):
|
if skipreason.startswith("Skipped: "):
|
||||||
skipreason = bin_xml_escape(skipreason[9:])
|
skipreason = skipreason[9:]
|
||||||
|
details = "%s:%s: %s" % (filename, lineno, skipreason)
|
||||||
|
|
||||||
self.append(
|
self.append(
|
||||||
Junit.skipped(
|
Junit.skipped(
|
||||||
"%s:%s: %s" % (filename, lineno, skipreason),
|
bin_xml_escape(details),
|
||||||
type="pytest.skip",
|
type="pytest.skip",
|
||||||
message=skipreason,
|
message=bin_xml_escape(skipreason),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.write_captured_output(report)
|
self.write_captured_output(report)
|
||||||
|
|
|
@ -1222,3 +1222,19 @@ def test_set_suite_name(testdir, suite_name):
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
node = dom.find_first_by_tag("testsuite")
|
node = dom.find_first_by_tag("testsuite")
|
||||||
node.assert_attr(name=expected)
|
node.assert_attr(name=expected)
|
||||||
|
|
||||||
|
|
||||||
|
def test_escaped_skipreason_issue3533(testdir):
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
import pytest
|
||||||
|
@pytest.mark.skip(reason='1 <> 2')
|
||||||
|
def test_skip():
|
||||||
|
pass
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
_, dom = runandparse(testdir)
|
||||||
|
node = dom.find_first_by_tag("testcase")
|
||||||
|
snode = node.find_first_by_tag("skipped")
|
||||||
|
assert "1 <> 2" in snode.text
|
||||||
|
snode.assert_attr(message="1 <> 2")
|
||||||
|
|
Loading…
Reference in New Issue