当前位置: 首页>>代码示例>>Python>>正文


Python weakref.CallableProxyType方法代码示例

本文整理汇总了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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_weakref.py

示例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) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:22,代码来源:test_weakref.py

示例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) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:22,代码来源:test_weakref.py

示例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 
开发者ID:dagbldr,项目名称:dagbldr,代码行数:11,代码来源:dill.py

示例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") 
开发者ID:sassoftware,项目名称:conary,代码行数:6,代码来源:api_tests.py


注:本文中的weakref.CallableProxyType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。