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

Method test_proxy_ref

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

Source from the content-addressed store, hash-verified

213 self.assertRaises(TypeError, weakref.ref, c, callback=None)
214
215 def test_proxy_ref(self):
216 o = C()
217 o.bar = 1
218 ref1 = weakref.proxy(o, self.callback)
219 ref2 = weakref.proxy(o, self.callback)
220 del o
221 gc_collect() # For PyPy or other GCs.
222
223 def check(proxy):
224 proxy.bar
225
226 self.assertRaises(ReferenceError, check, ref1)
227 self.assertRaises(ReferenceError, check, ref2)
228 ref3 = weakref.proxy(C())
229 gc_collect() # For PyPy or other GCs.
230 self.assertRaises(ReferenceError, bool, ref3)
231 self.assertEqual(self.cbcalled, 2)
232
233 @support.cpython_only
234 def test_proxy_repr(self):

Callers

nothing calls this directly

Calls 5

gc_collectFunction · 0.90
proxyMethod · 0.80
CClass · 0.70
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected