(pytester: Pytester, junit_logging: str)
| 1069 | |
| 1070 | @pytest.mark.parametrize("junit_logging", ["no", "system-out"]) |
| 1071 | def 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"]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…