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


Python interfaces.IConnector方法代码示例

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


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

示例1: test_connectStartsConnection

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IConnector [as 别名]
def test_connectStartsConnection(self):
        """
        When used with a successful endpoint, L{connect} will simulate all
        aspects of the connection process; C{buildProtocol}, C{connectionMade},
        C{dataReceived}.
        """
        self.assertIdentical(self.connector.getDestination(), self.endpoint)
        verifyObject(IConnector, self.connector)
        self.assertEqual(self.factory.starts, [self.connector])
        self.assertEqual(len(self.endpoint.attempts), 1)
        self.assertEqual(len(self.factory.built), 0)
        transport = self.connectionSucceeds()
        self.assertEqual(len(self.factory.built), 1)
        made = transport.protocol.made
        self.assertEqual(len(made), 1)
        self.assertIdentical(made[0], transport) 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:18,代码来源:test_adaptendpoint.py

示例2: test_interface

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IConnector [as 别名]
def test_interface(self):
        """
        The C{connect} method returns an object providing L{IConnector}.
        """
        reactor = self.buildReactor()
        connector = self.connect(reactor, ClientFactory())
        self.assertTrue(verifyObject(IConnector, connector)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:connectionmixins.py

示例3: test_interface

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IConnector [as 别名]
def test_interface(self):
        """
        L{srvconnect.SRVConnector} implements L{IConnector}.
        """
        verifyObject(IConnector, self.connector) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:7,代码来源:test_srvconnect.py

示例4: test_disconnectWhileConnecting

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IConnector [as 别名]
def test_disconnectWhileConnecting(self):
        """
        When the L{IConnector} is told to C{disconnect} before an in-progress
        L{Deferred} from C{connect} has fired, it will cancel that L{Deferred}.
        """
        self.connector.disconnect()
        self.assertEqual(len(self.factory.fails), 1)
        self.assertTrue(self.factory.fails[0].reason.check(CancelledError)) 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:10,代码来源:test_adaptendpoint.py

示例5: test_disconnectWhileConnected

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IConnector [as 别名]
def test_disconnectWhileConnected(self):
        """
        When the L{IConnector} is told to C{disconnect} while an existing
        connection is established, that connection will be dropped via
        C{loseConnection}.
        """
        transport = self.connectionSucceeds()
        self.factory.starts[0].disconnect()
        self.assertEqual(transport.lose, [transport]) 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:11,代码来源:test_adaptendpoint.py

示例6: test_connectAfterFailure

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IConnector [as 别名]
def test_connectAfterFailure(self):
        """
        When the L{IConnector} is told to C{connect} after a connection attempt
        has failed, a new connection attempt is started.
        """
        why = Failure(ZeroDivisionError())
        self.connectionFails(why)
        self.connector.connect()
        self.assertEqual(len(self.factory.starts), 2)
        self.assertEqual(len(self.endpoint.attempts), 2)
        self.connectionSucceeds() 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:13,代码来源:test_adaptendpoint.py

示例7: test_reConnectTooSoon

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IConnector [as 别名]
def test_reConnectTooSoon(self):
        """
        When the L{IConnector} is told to C{connect} while another attempt is
        still in flight, it synchronously raises L{RuntimeError}.
        """
        self.assertRaises(RuntimeError, self.connector.connect)
        self.assertEqual(len(self.factory.starts), 1)
        self.assertEqual(len(self.endpoint.attempts), 1) 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:10,代码来源:test_adaptendpoint.py

示例8: test_stopConnectingWhileConnected

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IConnector [as 别名]
def test_stopConnectingWhileConnected(self):
        """
        When the L{IConnector} is told to C{stopConnecting} while already
        connected, it raises a L{RuntimeError}.
        """
        self.connectionSucceeds()
        self.assertRaises(RuntimeError, self.connector.stopConnecting) 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:9,代码来源:test_adaptendpoint.py

示例9: test_stopConnectingWhileNotConnected

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IConnector [as 别名]
def test_stopConnectingWhileNotConnected(self):
        """
        When the L{IConnector} is told to C{stopConnecting} while it is not
        connected or connecting, it raises L{RuntimeError}.
        """
        self.connectionFails(Failure(ZeroDivisionError()))
        self.assertRaises(RuntimeError, self.connector.stopConnecting) 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:9,代码来源:test_adaptendpoint.py

示例10: test_interface

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IConnector [as 别名]
def test_interface(self):
        """
        L{IReactorUNIX.connectUNIX} returns an object providing L{IConnector}.
        """
        reactor = self.buildReactor()
        connector = reactor.connectUNIX(self.mktemp(), ClientFactory())
        self.assertTrue(verifyObject(IConnector, connector)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:9,代码来源:test_unix.py


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