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

Method check_basic_callback

Lib/test/test_weakref.py:258–267  ·  view source on GitHub ↗
(self, factory)

Source from the content-addressed store, hash-verified

256 "<ref>() should return original object if live")
257
258 def check_basic_callback(self, factory):
259 self.cbcalled = 0
260 o = factory()
261 ref = weakref.ref(o, self.callback)
262 del o
263 gc_collect() # For PyPy or other GCs.
264 self.assertEqual(self.cbcalled, 1,
265 "callback did not properly set 'cbcalled'")
266 self.assertIsNone(ref(),
267 "ref2 should be dead after deleting object reference")
268
269 def test_ref_reuse(self):
270 o = C()

Callers 2

test_basic_callbackMethod · 0.95
test_cfunctionMethod · 0.95

Calls 4

gc_collectFunction · 0.90
assertIsNoneMethod · 0.80
factoryFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected