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

Function test_nullbyte_replace

testing/test_junitxml.py:1093–1110  ·  testing/test_junitxml.py::test_nullbyte_replace
(pytester: Pytester, junit_logging: str)

Source from the content-addressed store, hash-verified

1091
1092@pytest.mark.parametrize(class="st">"junit_logging", [class="st">"no", class="st">"system-out"])
1093def test_nullbyte_replace(pytester: Pytester, junit_logging: str) -> None:
1094 class="cm"># Check if the null byte gets replaced
1095 pytester.makepyfile(
1096 class="st">"""
1097 import sys
1098 def test_print_nullbyte():
1099 sys.stdout.write(&class="cm">#x27;Here the null -->class="st">' + chr(0) + '<--')
1100 sys.stdout.write(&class="cm">#x27;In repr form -->class="st">' + repr(chr(0)) + '<--')
1101 assert False
1102 class="st">"""
1103 )
1104 xmlf = pytester.path.joinpath(class="st">"junit.xml")
1105 pytester.runpytest(fclass="st">"--junitxml={xmlf}", class="st">"-o", fclass="st">"junit_logging={junit_logging}")
1106 text = xmlf.read_text(encoding=class="st">"utf-8")
1107 if junit_logging == class="st">"system-out":
1108 assert class="st">"class="cm">#x0" in text
1109 if junit_logging == class="st">"no":
1110 assert class="st">"class="cm">#x0" not in text
1111
1112
1113def test_invalid_xml_escape() -> None:

Callers

nothing calls this directly

Calls 3

read_textMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected