本文整理汇总了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)
示例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))
示例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)
示例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))
示例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])
示例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()
示例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)
示例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)
示例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)
示例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))