Ensure that the broken pipe error message is suppressed. In some Python versions, it reaches sys.unraisablehook, in others a BrokenPipeError exception is propagated, but either way it prints to stderr on shutdown, so checking nothing is printed is enough.
(pytester: Pytester)
| 1281 | reason="Windows raises `OSError: [Errno 22] Invalid argument` instead", |
| 1282 | ) |
| 1283 | def test_no_brokenpipeerror_message(pytester: Pytester) -> None: |
| 1284 | """Ensure that the broken pipe error message is suppressed. |
| 1285 | |
| 1286 | In some Python versions, it reaches sys.unraisablehook, in others |
| 1287 | a BrokenPipeError exception is propagated, but either way it prints |
| 1288 | to stderr on shutdown, so checking nothing is printed is enough. |
| 1289 | """ |
| 1290 | popen = pytester.popen((*pytester._getpytestargs(), "--help")) |
| 1291 | popen.stdout.close() |
| 1292 | ret = popen.wait() |
| 1293 | assert popen.stderr.read() == b"" |
| 1294 | assert ret == 1 |
| 1295 | |
| 1296 | # Cleanup. |
| 1297 | popen.stderr.close() |
nothing calls this directly
no test coverage detected