本文整理汇总了Python中zope.interface.verify.verifyClass方法的典型用法代码示例。如果您正苦于以下问题:Python verify.verifyClass方法的具体用法?Python verify.verifyClass怎么用?Python verify.verifyClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zope.interface.verify
的用法示例。
在下文中一共展示了verify.verifyClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_verifyClass
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def test_verifyClass(self):
from zope.interface import Attribute
from zope.interface import Interface
from zope.interface.verify import verifyClass
class ICheckMe(Interface):
attr = Attribute(u'My attr')
def method():
pass
class CheckMe(object):
__implemented__ = ICheckMe
attr = 'value'
def method(self):
pass
self.assertTrue(verifyClass(ICheckMe, CheckMe))
示例2: test_verifyClass
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def test_verifyClass(self):
from zope.interface import Attribute
from zope.interface import Interface
from zope.interface.verify import verifyClass
class ICheckMe(Interface):
attr = Attribute(u'My attr')
def method():
"A method"
class CheckMe(object):
__implemented__ = ICheckMe
attr = 'value'
def method(self):
raise NotImplementedError()
self.assertTrue(verifyClass(ICheckMe, CheckMe))
示例3: testMissingAttr_with_Extended_Interface
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def testMissingAttr_with_Extended_Interface(self):
class II(Interface):
def f():
pass
class I(II):
pass
class C(object):
implements(I)
self.assertRaises(BrokenImplementation, verifyClass, I, C)
C.f=lambda self: None
verifyClass(I, C)
示例4: _callFUT
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def _callFUT(self, iface, klass):
from zope.interface.verify import verifyClass
return verifyClass(iface, klass)
示例5: test_class_misses_attribute_for_attribute
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def test_class_misses_attribute_for_attribute(self):
# This check *passes* for verifyClass
from zope.interface import Attribute
from zope.interface import Interface
from zope.interface import implementer
class ICurrent(Interface):
attr = Attribute("The foo Attribute")
@implementer(ICurrent)
class Current:
pass
self._callFUT(ICurrent, Current)
示例6: test_implementInterfaceIPushProducer
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def test_implementInterfaceIPushProducer(self):
"""
L{FileDescriptor} should implement L{IPushProducer}.
"""
self.assertTrue(verifyClass(IPushProducer, FileDescriptor))
示例7: test_reactorInterfaces
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def test_reactorInterfaces(self):
"""
Verify that IOCP socket-representing classes implement IReadWriteHandle
"""
self.assertTrue(verifyClass(IReadWriteHandle, tcp.Connection))
self.assertTrue(verifyClass(IReadWriteHandle, udp.Port))
示例8: test_interface
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def test_interface(self):
"""
L{server.DNSServerFactory} implements L{IProtocolFactory}.
"""
self.assertTrue(verifyClass(IProtocolFactory, server.DNSServerFactory))
示例9: test_interface
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def test_interface(self):
"""
L{ftp.BaseFTPRealm} implements L{IRealm}.
"""
self.assertTrue(verifyClass(IRealm, ftp.BaseFTPRealm))
示例10: __init__
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def __init__(self, resource_type_cls, maintainer):
assert verifyClass(IResourceType, resource_type_cls), \
type(resource_type_cls)
resource_cls_module = get_resource_class_module(resource_type_cls)
resource_cls_name = get_resource_class_name(resource_type_cls)
self.resource_type = ResourceType.by_resource_name(
resource_cls_module, resource_cls_name
)
self.maintainer = maintainer
示例11: test_interface
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def test_interface(self):
"""
The type returned by L{trivialInput} implements L{IRichInput}.
"""
self.assertTrue(verifyClass(IRichInput, trivialInput(Input.apple)))
示例12: testVerifyImplementation
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def testVerifyImplementation(self):
from zope.interface.verify import verifyClass
from zope.interface import Interface
from zope.interface.tests.unitfixtures import Foo
from zope.interface.tests.unitfixtures import FooInterface
from zope.interface.tests.unitfixtures import I1
self.assert_(verifyClass(FooInterface, Foo))
self.assert_(Interface.providedBy(I1))
示例13: testNotImplemented
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def testNotImplemented(self):
class C(object): pass
class I(Interface): pass
self.assertRaises(DoesNotImplement, verifyClass, I, C)
classImplements(C, I)
verifyClass(I, C)
示例14: testMissingAttr
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def testMissingAttr(self):
class I(Interface):
def f(): pass
class C(object):
implements(I)
self.assertRaises(BrokenImplementation, verifyClass, I, C)
C.f=lambda self: None
verifyClass(I, C)
示例15: testWrongArgs
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyClass [as 别名]
def testWrongArgs(self):
class I(Interface):
def f(a): pass
class C(object):
def f(self, b): pass
implements(I)
# We no longer require names to match.
#self.assertRaises(BrokenMethodImplementation, verifyClass, I, C)
C.f=lambda self, a: None
verifyClass(I, C)
C.f=lambda self, **kw: None
self.assertRaises(BrokenMethodImplementation, verifyClass, I, C)
C.f=lambda self, a, *args: None
verifyClass(I, C)
C.f=lambda self, a, *args, **kw: None
verifyClass(I, C)
C.f=lambda self, *args: None
verifyClass(I, C)