(self)
| 500 | self.assertEqual(file.buffer.raw.closefd, False) |
| 501 | |
| 502 | def test_garbage_collection(self): |
| 503 | # FileIO objects are collected, and collecting them flushes |
| 504 | # all data to disk. |
| 505 | # |
| 506 | # Note that using warnings_helper.check_warnings() will keep the |
| 507 | # file alive due to the `source` argument to warn(). So, use |
| 508 | # catch_warnings() instead. |
| 509 | with warnings.catch_warnings(): |
| 510 | warnings.simplefilter("ignore", ResourceWarning) |
| 511 | f = self.FileIO(os_helper.TESTFN, "wb") |
| 512 | f.write(b"abcxxx") |
| 513 | f.f = f |
| 514 | wr = weakref.ref(f) |
| 515 | del f |
| 516 | support.gc_collect() |
| 517 | self.assertIsNone(wr(), wr) |
| 518 | with self.open(os_helper.TESTFN, "rb") as f: |
| 519 | self.assertEqual(f.read(), b"abcxxx") |
| 520 | |
| 521 | def test_unbounded_file(self): |
| 522 | # Issue #1174606: reading from an unbounded stream such as /dev/zero. |
nothing calls this directly
no test coverage detected