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

Function test_no_brokenpipeerror_message

testing/acceptance_test.py:1283–1297  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1281 reason="Windows raises `OSError: [Errno 22] Invalid argument` instead",
1282)
1283def 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()

Callers

nothing calls this directly

Calls 4

_getpytestargsMethod · 0.80
popenMethod · 0.45
closeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected