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

Method test_read_closed

Lib/test/test_io/test_general.py:474–487  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

472 encoding="utf-8", closefd=False)
473
474 def test_read_closed(self):
475 with self.open(os_helper.TESTFN, "w", encoding="utf-8") as f:
476 f.write("egg\n")
477 with self.open(os_helper.TESTFN, "r", encoding="utf-8") as f:
478 file = self.open(f.fileno(), "r", encoding="utf-8", closefd=False)
479 self.assertEqual(file.read(), "egg\n")
480 file.seek(0)
481 file.close()
482 self.assertRaises(ValueError, file.read)
483 with self.open(os_helper.TESTFN, "rb") as f:
484 file = self.open(f.fileno(), "rb", closefd=False)
485 self.assertEqual(file.read()[:3], b"egg")
486 file.close()
487 self.assertRaises(ValueError, file.readinto, bytearray(1))
488
489 def test_no_closefd_with_filename(self):
490 # can't use closefd in combination with a file name

Callers

nothing calls this directly

Calls 8

openMethod · 0.45
writeMethod · 0.45
filenoMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45
seekMethod · 0.45
closeMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected