(self)
| 1459 | self.assertRaises(Exception, repr, t) |
| 1460 | |
| 1461 | def test_garbage_collection(self): |
| 1462 | # C TextIOWrapper objects are collected, and collecting them flushes |
| 1463 | # all data to disk. |
| 1464 | # The Python version has __del__, so it ends in gc.garbage instead. |
| 1465 | with warnings.catch_warnings(): |
| 1466 | warnings.simplefilter("ignore", ResourceWarning) |
| 1467 | rawio = self.FileIO(os_helper.TESTFN, "wb") |
| 1468 | b = self.BufferedWriter(rawio) |
| 1469 | t = self.TextIOWrapper(b, encoding="ascii") |
| 1470 | t.write("456def") |
| 1471 | t.x = t |
| 1472 | wr = weakref.ref(t) |
| 1473 | del t |
| 1474 | support.gc_collect() |
| 1475 | self.assertIsNone(wr(), wr) |
| 1476 | with self.open(os_helper.TESTFN, "rb") as f: |
| 1477 | self.assertEqual(f.read(), b"456def") |
| 1478 | |
| 1479 | def test_rwpair_cleared_before_textio(self): |
| 1480 | # Issue 13070: TextIOWrapper's finalization would crash when called |
nothing calls this directly
no test coverage detected