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

Method test_read_on_closed

Lib/test/test_io/test_bufferedio.py:514–534  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

512 "failed for {}: {} != 0".format(n, rawio._extraneous_reads))
513
514 def test_read_on_closed(self):
515 # Issue #23796
516 b = self.BufferedReader(self.BytesIO(b"12"))
517 b.read(1)
518 b.close()
519 with self.subTest('peek'):
520 self.assertRaises(ValueError, b.peek)
521 with self.subTest('read1'):
522 self.assertRaises(ValueError, b.read1, 1)
523 with self.subTest('read'):
524 self.assertRaises(ValueError, b.read)
525 with self.subTest('readinto'):
526 self.assertRaises(ValueError, b.readinto, bytearray())
527 with self.subTest('readinto1'):
528 self.assertRaises(ValueError, b.readinto1, bytearray())
529 with self.subTest('flush'):
530 self.assertRaises(ValueError, b.flush)
531 with self.subTest('truncate'):
532 self.assertRaises(ValueError, b.truncate)
533 with self.subTest('seek'):
534 self.assertRaises(ValueError, b.seek, 0)
535
536 def test_truncate_on_read_only(self):
537 rawio = self.MockFileIO(b"abc")

Callers

nothing calls this directly

Calls 4

readMethod · 0.95
closeMethod · 0.45
subTestMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected