(self)
| 50 | class FinalizationTest(unittest.TestCase): |
| 51 | |
| 52 | def test_frame_resurrect(self): |
| 53 | # A generator frame can be resurrected by a generator's finalization. |
| 54 | def gen(): |
| 55 | nonlocal frame |
| 56 | try: |
| 57 | yield |
| 58 | finally: |
| 59 | frame = sys._getframe() |
| 60 | |
| 61 | g = gen() |
| 62 | wr = weakref.ref(g) |
| 63 | next(g) |
| 64 | del g |
| 65 | support.gc_collect() |
| 66 | self.assertIs(wr(), None) |
| 67 | self.assertTrue(frame) |
| 68 | del frame |
| 69 | support.gc_collect() |
| 70 | |
| 71 | def test_refcycle(self): |
| 72 | # A generator caught in a refcycle gets finalized anyway. |
nothing calls this directly
no test coverage detected