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

Function test_nullbyte

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…