[py-svn] commit/pytest: RonnyPfannschmidt: fix issue #178 and extend the failure escape test
Bitbucket
commits-noreply at bitbucket.org
Fri Aug 17 16:08:47 CEST 2012
1 new commit in pytest:
https://bitbucket.org/hpk42/pytest/changeset/0f4d63deaf66/
changeset: 0f4d63deaf66
user: RonnyPfannschmidt
date: 2012-08-17 16:08:08
summary: fix issue #178 and extend the failure escape test
affected #: 3 files
diff -r 5c1e6d977aec371021a7ed527f4e362b8739d840 -r 0f4d63deaf661256b159f8f089999034c30e1d92 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -42,6 +42,8 @@
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 -r 5c1e6d977aec371021a7ed527f4e362b8739d840 -r 0f4d63deaf661256b159f8f089999034c30e1d92 _pytest/junitxml.py
--- a/_pytest/junitxml.py
+++ b/_pytest/junitxml.py
@@ -57,7 +57,7 @@
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 -r 5c1e6d977aec371021a7ed527f4e362b8739d840 -r 0f4d63deaf661256b159f8f089999034c30e1d92 testing/test_junitxml.py
--- a/testing/test_junitxml.py
+++ b/testing/test_junitxml.py
@@ -159,24 +159,27 @@
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("""
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list