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

Method check_flush_error_on_close

Lib/test/test_io/test_general.py:537–550  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

535 self.assertRaises(OverflowError, f.read)
536
537 def check_flush_error_on_close(self, *args, **kwargs):
538 # Test that the file is closed despite failed flush
539 # and that flush() is called before file closed.
540 f = self.open(*args, **kwargs)
541 closed = []
542 def bad_flush():
543 closed[:] = [f.closed]
544 raise OSError()
545 f.flush = bad_flush
546 self.assertRaises(OSError, f.close) # exception not swallowed
547 self.assertTrue(f.closed)
548 self.assertTrue(closed) # flush() called
549 self.assertFalse(closed[0]) # flush() called before file closed
550 f.flush = lambda: None # break reference loop
551
552 def test_flush_error_on_close(self):
553 # raw file

Callers 1

Calls 4

assertTrueMethod · 0.80
assertFalseMethod · 0.80
openMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected