MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_failure_escape

Method test_failure_escape

testing/test_junitxml.py:586–613  ·  view source on GitHub ↗
(
        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
    )

Source from the content-addressed store, hash-verified

584
585 @parametrize_families
586 def test_failure_escape(
587 self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
588 ) -> None:
589 pytester.makepyfile(
590 """
591 import pytest
592 @pytest.mark.parametrize('arg1', "<&'", ids="<&'")
593 def test_func(arg1):
594 print(arg1)
595 assert 0
596 """
597 )
598 result, dom = run_and_parse(
599 "-o", "junit_logging=system-out", family=xunit_family
600 )
601 assert result.ret
602 node = dom.find_first_by_tag("testsuite")
603 node.assert_attr(failures=3, tests=3)
604
605 for index, char in enumerate("<&'"):
606
607 tnode = node.find_nth_by_tag("testcase", index)
608 tnode.assert_attr(
609 classname="test_failure_escape", name="test_func[%s]" % char
610 )
611 sysout = tnode.find_first_by_tag("system-out")
612 text = sysout.text
613 assert "%s\n" % char in text
614
615 @parametrize_families
616 def test_junit_prefixing(

Callers

nothing calls this directly

Calls 5

run_and_parseFunction · 0.85
find_first_by_tagMethod · 0.80
assert_attrMethod · 0.80
find_nth_by_tagMethod · 0.80
makepyfileMethod · 0.45

Tested by

no test coverage detected