本文整理汇总了Python中zope.interface.verify.verifyObject方法的典型用法代码示例。如果您正苦于以下问题:Python verify.verifyObject方法的具体用法?Python verify.verifyObject怎么用?Python verify.verifyObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zope.interface.verify
的用法示例。
在下文中一共展示了verify.verifyObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_verifyObject
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_verifyObject(self):
from zope.interface import Attribute
from zope.interface import Interface
from zope.interface.verify import verifyObject
class ICheckMe(Interface):
attr = Attribute(u'My attr')
def method():
pass
class CheckMe(object):
__implemented__ = ICheckMe
attr = 'value'
def method(self):
pass
check_me = CheckMe()
self.assertTrue(verifyObject(ICheckMe, check_me))
示例2: test_class_misses_attribute_for_attribute
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_class_misses_attribute_for_attribute(self):
# This check *fails* for verifyObject
from zope.interface import Attribute
from zope.interface import Interface
from zope.interface import implementer
from zope.interface.exceptions import BrokenImplementation
class ICurrent(Interface):
attr = Attribute("The foo Attribute")
@implementer(ICurrent)
class Current:
pass
self.assertRaises(BrokenImplementation,
self._callFUT, ICurrent, Current)
示例3: test_interfaces
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_interfaces(self):
"""
L{server.GzipEncoderFactory} implements the
L{iweb._IRequestEncoderFactory} and its C{encoderForRequest} returns an
instance of L{server._GzipEncoder} which implements
L{iweb._IRequestEncoder}.
"""
request = server.Request(self.channel, False)
request.gotLength(0)
request.requestHeaders.setRawHeaders(b"Accept-Encoding",
[b"gzip,deflate"])
factory = server.GzipEncoderFactory()
self.assertTrue(verifyObject(iweb._IRequestEncoderFactory, factory))
encoder = factory.encoderForRequest(request)
self.assertTrue(verifyObject(iweb._IRequestEncoder, encoder))
示例4: test_checkHash
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_checkHash(self):
"""
L{DigestCredentialFactory.decode} returns an L{IUsernameDigestHash}
provider which can verify a hash of the form 'username:realm:password'.
"""
challenge = self.credentialFactory.getChallenge(
self.clientAddress.host)
nc = b"00000001"
clientResponse = self.formatResponse(
nonce=challenge['nonce'],
response=self.getDigestResponse(challenge, nc),
nc=nc,
opaque=challenge['opaque'])
creds = self.credentialFactory.decode(clientResponse, self.method,
self.clientAddress.host)
self.assertTrue(verifyObject(IUsernameDigestHash, creds))
cleartext = self.username + b":" + self.realm + b":" + self.password
hash = md5(cleartext)
self.assertTrue(creds.checkHash(hexlify(hash.digest())))
hash.update(b'wrong')
self.assertFalse(creds.checkHash(hexlify(hash.digest())))
示例5: test_connectDestination
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_connectDestination(self):
"""
L{MemoryReactor.connectTCP}, L{MemoryReactor.connectSSL}, and
L{MemoryReactor.connectUNIX} will return an L{IConnector} whose
C{getDestination} method returns an L{IAddress} with attributes which
reflect the values passed.
"""
memoryReactor = MemoryReactor()
for connector in [memoryReactor.connectTCP(
"test.example.com", 8321, ClientFactory()),
memoryReactor.connectSSL(
"test.example.com", 8321, ClientFactory(),
None)]:
verifyObject(IConnector, connector)
address = connector.getDestination()
verifyObject(IAddress, address)
self.assertEqual(address.host, "test.example.com")
self.assertEqual(address.port, 8321)
connector = memoryReactor.connectUNIX(b"/fake/path", ClientFactory())
verifyObject(IConnector, connector)
address = connector.getDestination()
verifyObject(IAddress, address)
self.assertEqual(address.name, b"/fake/path")
示例6: test_verifyObject
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_verifyObject(self):
from zope.interface import Attribute
from zope.interface import Interface
from zope.interface.verify import verifyObject
class ICheckMe(Interface):
attr = Attribute(u'My attr')
def method():
"A method"
class CheckMe(object):
__implemented__ = ICheckMe
attr = 'value'
def method(self):
raise NotImplementedError()
check_me = CheckMe()
self.assertTrue(verifyObject(ICheckMe, check_me))
示例7: test_staticmethod_hit_on_class
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_staticmethod_hit_on_class(self):
from zope.interface import Interface
from zope.interface import provider
from zope.interface.verify import verifyObject
class IFoo(Interface):
def bar(a, b):
"The bar method"
@provider(IFoo)
class Foo(object):
@staticmethod
def bar(a, b):
raise AssertionError("We're never actually called")
# Don't use self._callFUT, we don't want to instantiate the
# class.
verifyObject(IFoo, Foo)
示例8: _callFUT
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def _callFUT(self, iface, target):
from zope.interface.verify import verifyObject
if isinstance(target, (type, type(OldSkool))):
target = target()
return verifyObject(iface, target)
示例9: test_interface
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_interface(self):
"""
L{UserDirectory} instances provide L{resource.IResource}.
"""
self.assertTrue(verifyObject(resource.IResource, self.directory))
示例10: test_interface
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_interface(self):
"""
L{BasicCredentialFactory} implements L{ICredentialFactory}.
"""
self.assertTrue(
verifyObject(ICredentialFactory, self.credentialFactory))
示例11: test_interface
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_interface(self):
"""
L{FileBodyProducer} instances provide L{IBodyProducer}.
"""
self.assertTrue(verifyObject(
IBodyProducer, FileBodyProducer(BytesIO(b""))))
示例12: test_interface
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_interface(self):
"""
L{server.Request} instances provide L{iweb.IRequest}.
"""
self.assertTrue(
verifyObject(iweb.IRequest, server.Request(DummyChannel(), True)))
示例13: test_interface
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_interface(self):
"""
An instance of L{TagLoader} provides L{ITemplateLoader}.
"""
self.assertTrue(verifyObject(ITemplateLoader, self.loader))
示例14: test_interface
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_interface(self):
"""
L{ChunkedEncoder} instances provide L{IConsumer}.
"""
self.assertTrue(
verifyObject(IConsumer, ChunkedEncoder(StringTransport())))
示例15: test_verifyInterface
# 需要导入模块: from zope.interface import verify [as 别名]
# 或者: from zope.interface.verify import verifyObject [as 别名]
def test_verifyInterface(self):
"""
L{Response} instances provide L{IResponse}.
"""
response = justTransportResponse(StringTransport())
self.assertTrue(verifyObject(IResponse, response))