MCPcopy Index your code
hub / github.com/python/cpython / test_stdout_flush_at_shutdown

Method test_stdout_flush_at_shutdown

Lib/test/test_cmd_line.py:512–525  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

510
511 @force_not_colorized
512 def test_stdout_flush_at_shutdown(self):
513 # Issue #5319: if stdout.flush() fails at shutdown, an error should
514 # be printed out.
515 code = """if 1:
516 import os, sys, test.support
517 test.support.SuppressCrashReport().__enter__()
518 sys.stdout.write('x')
519 os.close(sys.stdout.fileno())"""
520 rc, out, err = assert_python_failure('-c', code)
521 self.assertEqual(b'', out)
522 self.assertEqual(120, rc)
523 self.assertIn(b'Exception ignored while flushing sys.stdout:\n'
524 b'OSError: '.replace(b'\n', os.linesep.encode()),
525 err)
526
527 def test_closed_stdout(self):
528 # Issue #13444: if stdout has been explicitly closed, we should

Callers

nothing calls this directly

Calls 5

assert_python_failureFunction · 0.90
assertInMethod · 0.80
assertEqualMethod · 0.45
replaceMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected