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


Python interface.Interface方法代码示例

本文整理汇总了Python中zope.interface.interface.Interface方法的典型用法代码示例。如果您正苦于以下问题:Python interface.Interface方法的具体用法?Python interface.Interface怎么用?Python interface.Interface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zope.interface.interface的用法示例。


在下文中一共展示了interface.Interface方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _makeInterfaces

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def _makeInterfaces():
    from zope.interface import Interface

    class IB0(Interface): pass
    class IB1(IB0): pass
    class IB2(IB0): pass
    class IB3(IB2, IB1): pass
    class IB4(IB1, IB2): pass

    class IF0(Interface): pass
    class IF1(IF0): pass

    class IR0(Interface): pass
    class IR1(IR0): pass

    return IB0, IB1, IB2, IB3, IB4, IF0, IF1, IR0, IR1 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:test_adapter.py

示例2: test_remove_extendor

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_remove_extendor(self):
        from zope.interface import Interface
        from zope.interface.interface import InterfaceClass
        IFoo = InterfaceClass('IFoo')
        IBar = InterfaceClass('IBar', IFoo)
        registry = self._makeRegistry(IFoo, IBar)
        alb = self._makeOne(registry)
        alb.remove_extendor(IFoo)
        self.assertEqual(sorted(alb._extendors.keys()),
                         sorted([IFoo, IBar, Interface]))
        self.assertEqual(alb._extendors[IFoo], [])
        self.assertEqual(alb._extendors[IBar], [IBar])
        self.assertEqual(sorted(alb._extendors[Interface]),
                         sorted([IBar]))

    # test '_subscribe' via its callers, '_uncached_lookup', etc. 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:test_adapter.py

示例3: test_pickles_with_utility_registration

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_pickles_with_utility_registration(self):
        import pickle
        comp = self._makeOne()
        utility = object()
        comp.registerUtility(
            utility,
            Interface)

        self.assertIs(utility,
                      comp.getUtility(Interface))

        comp2 = pickle.loads(pickle.dumps(comp))
        self.assertEqual(comp2.__name__, 'test')

        # The utility is still registered
        self.assertIsNotNone(comp2.getUtility(Interface))

        # We can register another one
        comp2.registerUtility(
            utility,
            Interface)
        self.assertIs(utility,
                      comp2.getUtility(Interface))

        self._check_equality_after_pickle(comp2) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:27,代码来源:test_registry.py

示例4: test_flattened_empty

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_flattened_empty(self):
        from zope.interface.interface import Interface
        decl = self._makeOne()
        self.assertEqual(list(decl.flattened()), [Interface]) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:6,代码来源:test_declarations.py

示例5: test_flattened_single_base

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_flattened_single_base(self):
        from zope.interface.interface import Interface
        from zope.interface.interface import InterfaceClass
        IFoo = InterfaceClass('IFoo')
        decl = self._makeOne(IFoo)
        self.assertEqual(list(decl.flattened()), [IFoo, Interface]) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_declarations.py

示例6: test_flattened_multiple_bases

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_flattened_multiple_bases(self):
        from zope.interface.interface import Interface
        from zope.interface.interface import InterfaceClass
        IFoo = InterfaceClass('IFoo')
        IBar = InterfaceClass('IBar')
        decl = self._makeOne(IFoo, IBar)
        self.assertEqual(list(decl.flattened()), [IFoo, IBar, Interface]) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:test_declarations.py

示例7: test_flattened_inheritance

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_flattened_inheritance(self):
        from zope.interface.interface import Interface
        from zope.interface.interface import InterfaceClass
        IFoo = InterfaceClass('IFoo')
        IBar = InterfaceClass('IBar', (IFoo,))
        decl = self._makeOne(IBar)
        self.assertEqual(list(decl.flattened()), [IBar, IFoo, Interface]) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:test_declarations.py

示例8: test_flattened_w_nested_sequence_overlap

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_flattened_w_nested_sequence_overlap(self):
        from zope.interface.interface import Interface
        from zope.interface.interface import InterfaceClass
        IFoo = InterfaceClass('IFoo')
        IBar = InterfaceClass('IBar')
        decl = self._makeOne(IBar, (IFoo, IBar))
        # Note that decl.__iro__ has IFoo first.
        self.assertEqual(list(decl.flattened()), [IFoo, IBar, Interface]) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:10,代码来源:test_declarations.py

示例9: test_ctor_w_registry_provided

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_ctor_w_registry_provided(self):
        from zope.interface import Interface
        from zope.interface.interface import InterfaceClass
        IFoo = InterfaceClass('IFoo')
        IBar = InterfaceClass('IBar', IFoo)
        registry = self._makeRegistry(IFoo, IBar)
        alb = self._makeOne(registry)
        self.assertEqual(sorted(alb._extendors.keys()),
                         sorted([IBar, IFoo, Interface]))
        self.assertEqual(alb._extendors[IFoo], [IFoo])
        self.assertEqual(alb._extendors[IBar], [IBar])
        self.assertEqual(sorted(alb._extendors[Interface]),
                         sorted([IFoo, IBar])) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:test_adapter.py

示例10: test_init_extendors_after_registry_update

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_init_extendors_after_registry_update(self):
        from zope.interface import Interface
        from zope.interface.interface import InterfaceClass
        IFoo = InterfaceClass('IFoo')
        IBar = InterfaceClass('IBar', IFoo)
        registry = self._makeRegistry()
        alb = self._makeOne(registry)
        registry._provided = [IFoo, IBar]
        alb.init_extendors()
        self.assertEqual(sorted(alb._extendors.keys()),
                         sorted([IBar, IFoo, Interface]))
        self.assertEqual(alb._extendors[IFoo], [IFoo])
        self.assertEqual(alb._extendors[IBar], [IBar])
        self.assertEqual(sorted(alb._extendors[Interface]),
                         sorted([IFoo, IBar])) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:17,代码来源:test_adapter.py

示例11: test_add_extendor

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_add_extendor(self):
        from zope.interface import Interface
        from zope.interface.interface import InterfaceClass
        IFoo = InterfaceClass('IFoo')
        IBar = InterfaceClass('IBar', IFoo)
        registry = self._makeRegistry()
        alb = self._makeOne(registry)
        alb.add_extendor(IFoo)
        alb.add_extendor(IBar)
        self.assertEqual(sorted(alb._extendors.keys()),
                         sorted([IBar, IFoo, Interface]))
        self.assertEqual(alb._extendors[IFoo], [IFoo])
        self.assertEqual(alb._extendors[IBar], [IBar])
        self.assertEqual(sorted(alb._extendors[Interface]),
                         sorted([IFoo, IBar])) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:17,代码来源:test_adapter.py

示例12: test_registerUtility_changes_object_identity_before

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_registerUtility_changes_object_identity_before(self):
        # If a subclass changes the identity of the _utility_registrations,
        # the cache is updated and the right thing still happens.
        class CompThatChangesAfter2Reg(self._getTargetClass()):
            reg_count = 0
            def registerUtility(self, *args):
                self.reg_count += 1
                if self.reg_count == 2:
                    self._utility_registrations = dict(self._utility_registrations)

                super(CompThatChangesAfter2Reg, self).registerUtility(*args)

        comp = CompThatChangesAfter2Reg()
        comp.registerUtility(object(), Interface)

        self.assertEqual(len(list(comp.registeredUtilities())), 1)

        class IFoo(Interface):
            pass

        comp.registerUtility(object(), IFoo)
        self.assertEqual(len(list(comp.registeredUtilities())), 2)


        class IBar(Interface):
            pass

        comp.registerUtility(object(), IBar)
        self.assertEqual(len(list(comp.registeredUtilities())), 3) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:31,代码来源:test_registry.py

示例13: test_registerAdapter_w_required_containing_None

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test_registerAdapter_w_required_containing_None(self):
        from zope.interface.declarations import InterfaceClass
        from zope.interface.interface import Interface
        from zope.interface.interfaces import Registered
        from zope.interface.registry import AdapterRegistration

        class IFoo(InterfaceClass):
            pass
        ifoo = IFoo('IFoo')
        _info = u'info'
        _name = u'name'
        class _Factory(object):
            pass
        comp = self._makeOne()
        _monkey, _events = self._wrapEvents()
        with _monkey:
            comp.registerAdapter(_Factory, [None], provided=ifoo,
                                 name=_name, info=_info)
        self.assertTrue(comp.adapters._adapters[1][Interface][ifoo][_name]
                        is _Factory)
        self.assertEqual(comp._adapter_registrations[(Interface,), ifoo, _name],
                         (_Factory, _info))
        self.assertEqual(len(_events), 1)
        args, kw = _events[0]
        event, = args
        self.assertEqual(kw, {})
        self.assertTrue(isinstance(event, Registered))
        self.assertTrue(isinstance(event.object, AdapterRegistration))
        self.assertTrue(event.object.registry is comp)
        self.assertTrue(event.object.provided is ifoo)
        self.assertEqual(event.object.required, (Interface,))
        self.assertTrue(event.object.name is _name)
        self.assertTrue(event.object.info is _info)
        self.assertTrue(event.object.factory is _Factory) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:36,代码来源:test_registry.py

示例14: test__convert_None_to_Interface_w_None

# 需要导入模块: from zope.interface import interface [as 别名]
# 或者: from zope.interface.interface import Interface [as 别名]
def test__convert_None_to_Interface_w_None(self):
        from zope.interface.adapter import _convert_None_to_Interface
        from zope.interface.interface import Interface
        self.assertTrue(_convert_None_to_Interface(None) is Interface) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:6,代码来源:test_adapter.py


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