fix issue #178 and extend the failure escape test
This commit is contained in:
parent
aa84359bd9
commit
1446b4b4e6
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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("""
|
||||
|
|
Loading…
Reference in New Issue