(pytester: Pytester, junit_logging: str)
| 1003 | |
| 1004 | @pytest.mark.parametrize("junit_logging", ["no", "system-out"]) |
| 1005 | def 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"]) |
nothing calls this directly
no test coverage detected