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

Method test_saveall

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected