本文整理汇总了Python中weakref.CallableProxyType方法的典型用法代码示例。如果您正苦于以下问题:Python weakref.CallableProxyType方法的具体用法?Python weakref.CallableProxyType怎么用?Python weakref.CallableProxyType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weakref
的用法示例。
在下文中一共展示了weakref.CallableProxyType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_callable_proxy
# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import CallableProxyType [as 别名]
def test_callable_proxy(self):
o = Callable()
ref1 = weakref.proxy(o)
self.check_proxy(o, ref1)
self.assertIs(type(ref1), weakref.CallableProxyType,
"proxy is not of callable type")
ref1('twinkies!')
self.assertEqual(o.bar, 'twinkies!',
"call through proxy not passed through to original")
ref1(x='Splat.')
self.assertEqual(o.bar, 'Splat.',
"call through proxy not passed through to original")
# expect due to too few args
self.assertRaises(TypeError, ref1)
# expect due to too many args
self.assertRaises(TypeError, ref1, 1, 2, 3)
示例2: test_callable_proxy
# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import CallableProxyType [as 别名]
def test_callable_proxy(self):
o = Callable()
ref1 = weakref.proxy(o)
self.check_proxy(o, ref1)
self.assertTrue(type(ref1) is weakref.CallableProxyType,
"proxy is not of callable type")
ref1('twinkies!')
self.assertTrue(o.bar == 'twinkies!',
"call through proxy not passed through to original")
ref1(x='Splat.')
self.assertTrue(o.bar == 'Splat.',
"call through proxy not passed through to original")
# expect due to too few args
self.assertRaises(TypeError, ref1)
# expect due to too many args
self.assertRaises(TypeError, ref1, 1, 2, 3)
示例3: test_callable_proxy
# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import CallableProxyType [as 别名]
def test_callable_proxy(self):
o = Callable()
ref1 = weakref.proxy(o)
self.check_proxy(o, ref1)
self.assert_(type(ref1) is weakref.CallableProxyType,
"proxy is not of callable type")
ref1('twinkies!')
self.assert_(o.bar == 'twinkies!',
"call through proxy not passed through to original")
ref1(x='Splat.')
self.assert_(o.bar == 'Splat.',
"call through proxy not passed through to original")
# expect due to too few args
self.assertRaises(TypeError, ref1)
# expect due to too many args
self.assertRaises(TypeError, ref1, 1, 2, 3)
示例4: save_weakproxy
# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import CallableProxyType [as 别名]
def save_weakproxy(pickler, obj):
refobj = _locate_object(_proxy_helper(obj))
try: log.info("R2: %s" % obj)
except ReferenceError: log.info("R3: %s" % sys.exc_info()[1])
#callable = bool(getattr(refobj, '__call__', None))
if type(obj) is CallableProxyType: callable = True
else: callable = False
pickler.save_reduce(_create_weakproxy, (refobj, callable), obj=obj)
return
示例5: CheckCursorConnection
# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import CallableProxyType [as 别名]
def CheckCursorConnection(self):
if not isinstance(self.cur.connection, weakref.ProxyType) and \
not isinstance(self.cur.connection, weakref.CallableProxyType):
fail("cursor.connection doesn't return the correct type")