當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。