MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_refcycle

Method test_refcycle

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

Source from the content-addressed store, hash-verified

70
71 @unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: False is not true
72 def test_refcycle(self):
73 # A generator caught in a refcycle gets finalized anyway.
74 old_garbage = gc.garbage[:]
75 finalized = False
76 def gen():
77 nonlocal finalized
78 try:
79 g = yield
80 yield 1
81 finally:
82 finalized = True
83
84 g = gen()
85 next(g)
86 g.send(g)
87 self.assertGreaterEqual(sys.getrefcount(g), 2)
88 self.assertFalse(finalized)
89 del g
90 support.gc_collect()
91 self.assertTrue(finalized)
92 self.assertEqual(gc.garbage, old_garbage)
93
94 def test_lambda_generator(self):
95 # bpo-23192, gh-119897: Test that a lambda returning a generator behaves

Callers

nothing calls this directly

Calls 7

nextFunction · 0.85
assertGreaterEqualMethod · 0.80
assertFalseMethod · 0.80
assertTrueMethod · 0.80
genFunction · 0.70
sendMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected