本文整理匯總了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))