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


Python verify.verifyObject方法代码示例

本文整理汇总了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)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:test_interface.py

示例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) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:test_verify.py

示例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)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:test_web.py

示例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()))) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:26,代码来源:test_digestauth.py

示例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") 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:25,代码来源:test_stringtransport.py

示例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)) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:24,代码来源:test_interface.py

示例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) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:22,代码来源:test_verify.py

示例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) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:7,代码来源:test_verify.py

示例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)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:7,代码来源:test_distrib.py

示例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)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_httpauth.py

示例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"")))) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_agent.py

示例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))) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_web.py

示例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)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:7,代码来源:test_template.py

示例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()))) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_newclient.py

示例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)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_newclient.py


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