MCPcopy
hub / github.com/pytest-dev/pytest / test_nullbyte

Function test_nullbyte

testing/test_junitxml.py:1071–1089  ·  testing/test_junitxml.py::test_nullbyte
(pytester: Pytester, junit_logging: str)

Source from the content-addressed store, hash-verified

1069
1070@pytest.mark.parametrize(class="st">"junit_logging", [class="st">"no", class="st">"system-out"])
1071def test_nullbyte(pytester: Pytester, junit_logging: str) -> None:
1072 class="cm"># A null byte cannot occur in XML (see section 2.2 of the spec)
1073 pytester.makepyfile(
1074 class="st">"""
1075 import sys
1076 def test_print_nullbyte():
1077 sys.stdout.write(&class="cm">#x27;Here the null -->class="st">' + chr(0) + '<--')
1078 sys.stdout.write(&class="cm">#x27;In repr form -->class="st">' + repr(chr(0)) + '<--')
1079 assert False
1080 class="st">"""
1081 )
1082 xmlf = pytester.path.joinpath(class="st">"junit.xml")
1083 pytester.runpytest(fclass="st">"--junitxml={xmlf}", class="st">"-o", fclass="st">"junit_logging={junit_logging}")
1084 text = xmlf.read_text(encoding=class="st">"utf-8")
1085 assert class="st">"\x00" not in text
1086 if junit_logging == class="st">"system-out":
1087 assert class="st">"class="cm">#x00" in text
1088 if junit_logging == class="st">"no":
1089 assert class="st">"class="cm">#x00" not in text
1090
1091
1092@pytest.mark.parametrize(class="st">"junit_logging", [class="st">"no", class="st">"system-out"])

Callers

nothing calls this directly

Calls 3

read_textMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected