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

Function test_nullbyte_replace

testing/test_junitxml.py:1027–1044  ·  view source on GitHub ↗
(pytester: Pytester, junit_logging: str)

Source from the content-addressed store, hash-verified

1025
1026@pytest.mark.parametrize("junit_logging", ["no", "system-out"])
1027def test_nullbyte_replace(pytester: Pytester, junit_logging: str) -> None:
1028 # Check if the null byte gets replaced
1029 pytester.makepyfile(
1030 """
1031 import sys
1032 def test_print_nullbyte():
1033 sys.stdout.write('Here the null -->' + chr(0) + '<--')
1034 sys.stdout.write('In repr form -->' + repr(chr(0)) + '<--')
1035 assert False
1036 """
1037 )
1038 xmlf = pytester.path.joinpath("junit.xml")
1039 pytester.runpytest("--junitxml=%s" % xmlf, "-o", "junit_logging=%s" % junit_logging)
1040 text = xmlf.read_text()
1041 if junit_logging == "system-out":
1042 assert "#x0" in text
1043 if junit_logging == "no":
1044 assert "#x0" not in text
1045
1046
1047def test_invalid_xml_escape() -> None:

Callers

nothing calls this directly

Calls 2

makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected