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

Method test_multiple_callbacks

Lib/test/test_weakref.py:182–191  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

180 self.check_basic_callback(create_cfunction)
181
182 def test_multiple_callbacks(self):
183 o = C()
184 ref1 = weakref.ref(o, self.callback)
185 ref2 = weakref.ref(o, self.callback)
186 del o
187 gc_collect() # For PyPy or other GCs.
188 self.assertIsNone(ref1(), "expected reference to be invalidated")
189 self.assertIsNone(ref2(), "expected reference to be invalidated")
190 self.assertEqual(self.cbcalled, 2,
191 "callback not called the right number of times")
192
193 def test_multiple_selfref_callbacks(self):
194 # Make sure all references are invalidated before callbacks are called

Callers

nothing calls this directly

Calls 4

gc_collectFunction · 0.90
assertIsNoneMethod · 0.80
CClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected