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

Method test_bug1055820b

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

Source from the content-addressed store, hash-verified

659 self.assertTrue(gc.is_finalized(lazarus))
660
661 def test_bug1055820b(self):
662 # Corresponds to temp2b.py in the bug report.
663
664 ouch = []
665 def callback(ignored):
666 ouch[:] = [wr() for wr in WRs]
667
668 Cs = [C1055820(i) for i in range(2)]
669 WRs = [weakref.ref(c, callback) for c in Cs]
670 c = None
671
672 gc.collect()
673 self.assertEqual(len(ouch), 0)
674 # Make the two instances trash, and collect again. The bug was that
675 # the callback materialized a strong reference to an instance, but gc
676 # cleared the instance's dict anyway.
677 Cs = None
678 gc.collect()
679 self.assertEqual(len(ouch), 2) # else the callbacks didn't run
680 for x in ouch:
681 # The weakref should be cleared before executing the callback.
682 self.assertIsNone(x)
683
684 def test_bug21435(self):
685 # This is a poor test - its only virtue is that it happened to

Callers

nothing calls this directly

Calls 4

C1055820Class · 0.85
assertIsNoneMethod · 0.80
collectMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected