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

Method test_callable_proxy

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

Source from the content-addressed store, hash-verified

404 self.assertIs(p1, p2, "callbacks were None, NULL in the C API")
405
406 def test_callable_proxy(self):
407 o = Callable()
408 ref1 = weakref.proxy(o)
409
410 self.check_proxy(o, ref1)
411
412 self.assertIs(type(ref1), weakref.CallableProxyType,
413 "proxy is not of callable type")
414 ref1('twinkies!')
415 self.assertEqual(o.bar, 'twinkies!',
416 "call through proxy not passed through to original")
417 ref1(x='Splat.')
418 self.assertEqual(o.bar, 'Splat.',
419 "call through proxy not passed through to original")
420
421 # expect due to too few args
422 self.assertRaises(TypeError, ref1)
423
424 # expect due to too many args
425 self.assertRaises(TypeError, ref1, 1, 2, 3)
426
427 def check_proxy(self, o, proxy):
428 o.foo = 1

Callers

nothing calls this directly

Calls 6

check_proxyMethod · 0.95
proxyMethod · 0.80
CallableClass · 0.70
assertIsMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected