(self)
| 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 |
nothing calls this directly
no test coverage detected