fix issue104 properly xml-escape names in junitxml files
--HG-- branch : trunk
This commit is contained in:
parent
523704f890
commit
0c04577f9f
|
@ -31,6 +31,7 @@ New features
|
||||||
Bug fixes / Maintenance
|
Bug fixes / Maintenance
|
||||||
++++++++++++++++++++++++++
|
++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
- fix issue104 proper escaping for test names in junitxml plugin
|
||||||
- fix issue57 -f|--looponfail to work with xpassing tests
|
- fix issue57 -f|--looponfail to work with xpassing tests
|
||||||
- fix pyimport() to work with directories
|
- fix pyimport() to work with directories
|
||||||
- streamline py.path.local.mkdtemp implementation and usage
|
- streamline py.path.local.mkdtemp implementation and usage
|
||||||
|
|
|
@ -37,7 +37,7 @@ class LogXML(object):
|
||||||
d = {'time': self._durations.pop(report.item, "0")}
|
d = {'time': self._durations.pop(report.item, "0")}
|
||||||
names = [x.replace(".py", "") for x in node.listnames() if x != "()"]
|
names = [x.replace(".py", "") for x in node.listnames() if x != "()"]
|
||||||
d['classname'] = ".".join(names[:-1])
|
d['classname'] = ".".join(names[:-1])
|
||||||
d['name'] = names[-1]
|
d['name'] = py.xml.escape(names[-1])
|
||||||
attrs = ['%s="%s"' % item for item in sorted(d.items())]
|
attrs = ['%s="%s"' % item for item in sorted(d.items())]
|
||||||
self.test_logs.append("\n<testcase %s>" % " ".join(attrs))
|
self.test_logs.append("\n<testcase %s>" % " ".join(attrs))
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class LogXML(object):
|
||||||
d = {'time': '???'}
|
d = {'time': '???'}
|
||||||
names = [x.replace(".py", "") for x in node.listnames() if x != "()"]
|
names = [x.replace(".py", "") for x in node.listnames() if x != "()"]
|
||||||
d['classname'] = ".".join(names[:-1])
|
d['classname'] = ".".join(names[:-1])
|
||||||
d['name'] = names[-1]
|
d['name'] = py.xml.escape(names[-1])
|
||||||
attrs = ['%s="%s"' % item for item in sorted(d.items())]
|
attrs = ['%s="%s"' % item for item in sorted(d.items())]
|
||||||
self.test_logs.append("\n<testcase %s>" % " ".join(attrs))
|
self.test_logs.append("\n<testcase %s>" % " ".join(attrs))
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,27 @@ class TestPython:
|
||||||
assert_attr(fnode, message="test failure")
|
assert_attr(fnode, message="test failure")
|
||||||
assert "ValueError" in fnode.toxml()
|
assert "ValueError" in fnode.toxml()
|
||||||
|
|
||||||
|
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))
|
||||||
|
def test_func(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.test_failure_escape",
|
||||||
|
name="test_func[<]")
|
||||||
|
tnode = node.getElementsByTagName("testcase")[1]
|
||||||
|
assert_attr(tnode,
|
||||||
|
classname="test_failure_escape.test_failure_escape",
|
||||||
|
name="test_func[&]")
|
||||||
|
|
||||||
def test_xfailure_function(self, testdir):
|
def test_xfailure_function(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import py
|
import py
|
||||||
|
|
Loading…
Reference in New Issue