From 963b944e795a1c434ac87e29bccd2abd5d0388c9 Mon Sep 17 00:00:00 2001 From: Jaap Broekhuizen Date: Wed, 8 May 2013 15:15:43 +0200 Subject: [PATCH 1/3] Fix junitxml generation when using special characters in parametrized tests. --- _pytest/junitxml.py | 5 +++-- pytest.py | 0 2 files changed, 3 insertions(+), 2 deletions(-) mode change 100644 => 100755 pytest.py diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py index b4ffccfe2..cac51b55b 100644 --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -36,7 +36,8 @@ class Junit(py.xml.Namespace): # | [#x10000-#x10FFFF] _legal_chars = (0x09, 0x0A, 0x0d) _legal_ranges = ( - (0x20, 0xD7FF), + (0x20, 0x7E), + (0x80, 0xD7FF), (0xE000, 0xFFFD), (0x10000, 0x10FFFF), ) @@ -103,7 +104,7 @@ class LogXML(object): classnames.insert(0, self.prefix) self.tests.append(Junit.testcase( classname=".".join(classnames), - name=names[-1], + name=bin_xml_escape(names[-1]), time=getattr(report, 'duration', 0) )) diff --git a/pytest.py b/pytest.py old mode 100644 new mode 100755 From 0e5f2847f1667d57168a0e157c62d17cb6e60b6e Mon Sep 17 00:00:00 2001 From: Jaap Broekhuizen Date: Wed, 8 May 2013 16:11:55 +0200 Subject: [PATCH 2/3] Fix pytest.py permissions. --- pytest.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 pytest.py diff --git a/pytest.py b/pytest.py old mode 100755 new mode 100644 From 7803bca335646df1e4155fa9e5464e193d16b466 Mon Sep 17 00:00:00 2001 From: Jaap Broekhuizen Date: Thu, 9 May 2013 21:16:57 +0200 Subject: [PATCH 3/3] Implemented a test for xml control character fail. --- testing/test_junitxml.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index dbb814961..139ba50e5 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -450,3 +450,16 @@ def test_logxml_changingdir(testdir): assert result.ret == 0 assert testdir.tmpdir.join("a/x.xml").check() +def test_escaped_parametrized_names_xml(testdir): + testdir.makepyfile(""" + import pytest + @pytest.mark.parametrize('char', ["\\x00"]) + def test_func(char): + assert char + """) + result, dom = runandparse(testdir) + assert result.ret == 0 + node = dom.getElementsByTagName("testcase")[0] + assert_attr(node, + name="test_func[#x00]") +