diff --git a/CHANGELOG b/CHANGELOG index aba6fd8f8..ce74c0740 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -42,6 +42,8 @@ Changes between 2.2.4 and 2.3.0.dev especially with respect to the "magic" history, also mention pytest-django, trial and unittest integration. +- fix issue 178: xml binary escapes are now wrapped in py.xml.raw + - reporting refinements: - pytest_report_header now receives a "startdir" so that diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py index acf347bd9..117e0bd12 100644 --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -57,7 +57,7 @@ def bin_xml_escape(arg): return unicode('#x%02X') % i else: return unicode('#x%04X') % i - return illegal_xml_re.sub(repl, py.xml.escape(arg)) + return py.xml.raw(illegal_xml_re.sub(repl, py.xml.escape(arg))) def pytest_addoption(parser): group = parser.getgroup("terminal reporting") diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 1f99b85d8..5c30487d0 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -159,24 +159,27 @@ class TestPython: def test_failure_escape(self, testdir): testdir.makepyfile(""" - def pytest_generate_tests(metafunc): - metafunc.addcall(id="<", funcargs=dict(arg1=42)) - metafunc.addcall(id="&", funcargs=dict(arg1=44)) + import pytest + @pytest.mark.parametrize('arg1', "<&'", ids="<&'") def test_func(arg1): + print arg1 assert 0 """) result, dom = runandparse(testdir) assert result.ret node = dom.getElementsByTagName("testsuite")[0] - assert_attr(node, failures=2, tests=2) - tnode = node.getElementsByTagName("testcase")[0] - assert_attr(tnode, - classname="test_failure_escape", - name="test_func[<]") - tnode = node.getElementsByTagName("testcase")[1] - assert_attr(tnode, - classname="test_failure_escape", - name="test_func[&]") + assert_attr(node, failures=3, tests=3) + + for index, char in enumerate("<&'"): + + tnode = node.getElementsByTagName("testcase")[index] + assert_attr(tnode, + classname="test_failure_escape", + name="test_func[%s]" % char) + sysout = tnode.getElementsByTagName('system-out')[0] + text = sysout.childNodes[0].wholeText + assert text == '%s\n' % char + def test_junit_prefixing(self, testdir): testdir.makepyfile("""