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

Method test_legacy_finalizer

Lib/test/test_gc.py:177–200  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

175
176 @cpython_only
177 def test_legacy_finalizer(self):
178 # A() is uncollectable if it is part of a cycle, make sure it shows up
179 # in gc.garbage.
180 @with_tp_del
181 class A:
182 def __tp_del__(self): pass
183 class B:
184 pass
185 a = A()
186 a.a = a
187 id_a = id(a)
188 b = B()
189 b.b = b
190 gc.collect()
191 del a
192 del b
193 self.assertNotEqual(gc.collect(), 0)
194 for obj in gc.garbage:
195 if id(obj) == id_a:
196 del obj.a
197 break
198 else:
199 self.fail("didn't find obj in garbage (finalizer)")
200 gc.garbage.remove(obj)
201
202 @cpython_only
203 def test_legacy_finalizer_newclass(self):

Callers

nothing calls this directly

Calls 7

idFunction · 0.85
assertNotEqualMethod · 0.80
AClass · 0.70
BClass · 0.70
collectMethod · 0.45
failMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected