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

Function test_nullbyte

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

Source from the content-addressed store, hash-verified

1003
1004@pytest.mark.parametrize("junit_logging", ["no", "system-out"])
1005def test_nullbyte(pytester: Pytester, junit_logging: str) -> None:
1006 # A null byte can not occur in XML (see section 2.2 of the spec)
1007 pytester.makepyfile(
1008 """
1009 import sys
1010 def test_print_nullbyte():
1011 sys.stdout.write('Here the null -->' + chr(0) + '<--')
1012 sys.stdout.write('In repr form -->' + repr(chr(0)) + '<--')
1013 assert False
1014 """
1015 )
1016 xmlf = pytester.path.joinpath("junit.xml")
1017 pytester.runpytest("--junitxml=%s" % xmlf, "-o", "junit_logging=%s" % junit_logging)
1018 text = xmlf.read_text()
1019 assert "\x00" not in text
1020 if junit_logging == "system-out":
1021 assert "#x00" in text
1022 if junit_logging == "no":
1023 assert "#x00" not in text
1024
1025
1026@pytest.mark.parametrize("junit_logging", ["no", "system-out"])

Callers

nothing calls this directly

Calls 2

makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected