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

Method test_frame_resurrect

Lib/test/test_generators.py:52–69  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

50class 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.

Callers

nothing calls this directly

Calls 3

assertTrueMethod · 0.80
genFunction · 0.70
assertIsMethod · 0.45

Tested by

no test coverage detected