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

Method test_saveall

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

Source from the content-addressed store, hash-verified

338 self.assertEqual(gc.collect(), 1)
339
340 def test_saveall(self):
341 # Verify that cyclic garbage like lists show up in gc.garbage if the
342 # SAVEALL option is enabled.
343
344 # First make sure we don't save away other stuff that just happens to
345 # be waiting for collection.
346 gc.collect()
347 # if this fails, someone else created immortal trash
348 self.assertEqual(gc.garbage, [])
349
350 L = []
351 L.append(L)
352 id_L = id(L)
353
354 debug = gc.get_debug()
355 gc.set_debug(debug | gc.DEBUG_SAVEALL)
356 del L
357 gc.collect()
358 gc.set_debug(debug)
359
360 self.assertEqual(len(gc.garbage), 1)
361 obj = gc.garbage.pop()
362 self.assertEqual(id(obj), id_L)
363
364 def test_del(self):
365 # __del__ methods can trigger collection, make this to happen

Callers

nothing calls this directly

Calls 7

idFunction · 0.85
collectMethod · 0.45
assertEqualMethod · 0.45
appendMethod · 0.45
get_debugMethod · 0.45
set_debugMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected