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


Python StringTransport.protocol方法代码示例

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


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

示例1: test_data_cancels_timeout

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import protocol [as 别名]
    def test_data_cancels_timeout(self):
        """
        When data is received, the timeout is canceled
        """
        clock = Clock()
        protocol = HangCheckProtocol(Protocol(), reactor=clock)
        transport = StringTransport()

        transport.protocol = protocol
        protocol.makeConnection(transport)
        protocol.dataReceived('some-data')
        assert_clock_idle(self, clock)
开发者ID:nand0p,项目名称:buildbot,代码行数:14,代码来源:test_util_hangcheck.py

示例2: test_transport

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import protocol [as 别名]
    def test_transport(self):
        """
        The transport passed to the underlying protocol is
        the underlying transport.
        """
        clock = Clock()
        wrapped_protocol = Protocol()
        protocol = HangCheckProtocol(wrapped_protocol, reactor=clock)
        transport = StringTransport()

        transport.protocol = protocol
        protocol.makeConnection(transport)

        self.assertIdentical(wrapped_protocol.transport, transport)
开发者ID:nand0p,项目名称:buildbot,代码行数:16,代码来源:test_util_hangcheck.py

示例3: test_forwards_data

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import protocol [as 别名]
    def test_forwards_data(self):
        """
        Data received by the protocol gets passed to the wrapped
        protocol.
        """
        clock = Clock()
        wrapped_protocol = AccumulatingProtocol()
        protocol = HangCheckProtocol(wrapped_protocol, reactor=clock)
        transport = StringTransport()

        transport.protocol = protocol
        protocol.makeConnection(transport)
        protocol.dataReceived('some-data')

        self.assertEqual(wrapped_protocol.data, "some-data")
开发者ID:nand0p,项目名称:buildbot,代码行数:17,代码来源:test_util_hangcheck.py

示例4: connect

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import protocol [as 别名]
    def connect(self, factory):
        """
        Connect the given L{IProtocolFactory} to a L{StringTransport} and
        return a fired L{Deferred}.

        @param factory: see L{IStreamClientEndpoint}

        @return: see L{IStreamClientEndpoint}
        """
        protocol = factory.buildProtocol(None)
        transport = StringTransport()
        transport.protocol = protocol
        protocol.makeConnection(transport)
        self.transports.append(transport)
        return succeed(protocol)
开发者ID:tehasdf,项目名称:tubes,代码行数:17,代码来源:util.py

示例5: test_disconnects

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import protocol [as 别名]
    def test_disconnects(self):
        """
        When connecting to a server that doesn't send any data,
        the protocol disconnects after the timeout.
        """
        clock = Clock()
        protocol = HangCheckProtocol(Protocol(), reactor=clock)
        transport = StringTransport()

        transport.protocol = protocol
        protocol.makeConnection(transport)

        clock.advance(120)
        self.assertTrue(transport.disconnecting)
        assert_clock_idle(self, clock)
开发者ID:nand0p,项目名称:buildbot,代码行数:17,代码来源:test_util_hangcheck.py

示例6: test_disconnect_cancels_timeout

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import protocol [as 别名]
    def test_disconnect_cancels_timeout(self):
        """
        If the connection is closed, the hang check is cancelled.
        """
        clock = Clock()
        protocol = HangCheckProtocol(
            Protocol(),
            reactor=clock,
        )
        transport = StringTransport()

        transport.protocol = protocol
        protocol.makeConnection(transport)
        protocol.connectionLost(
            Failure(ConnectionDone("Bye."))
        )

        assert_clock_idle(self, clock)
开发者ID:nand0p,项目名称:buildbot,代码行数:20,代码来源:test_util_hangcheck.py

示例7: test_data_and_disconnect

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import protocol [as 别名]
    def test_data_and_disconnect(self):
        """
        If the connection receives data and then is closed, no error results.
        """
        clock = Clock()
        protocol = HangCheckProtocol(
            Protocol(),
            reactor=clock,
        )
        transport = StringTransport()

        transport.protocol = protocol
        protocol.makeConnection(transport)
        protocol.dataReceived("some-data")
        protocol.connectionLost(
            Failure(ConnectionDone("Bye."))
        )

        assert_clock_idle(self, clock)
开发者ID:nand0p,项目名称:buildbot,代码行数:21,代码来源:test_util_hangcheck.py

示例8: test_calls_callback

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import protocol [as 别名]
    def test_calls_callback(self):
        """
        When connecting to a server that doesn't send any data,
        the protocol calls the hung callback.
        """
        results = []
        clock = Clock()
        protocol = HangCheckProtocol(
            Protocol(),
            hung_callback=lambda: results.append(True),
            reactor=clock,
        )
        transport = StringTransport()

        transport.protocol = protocol
        protocol.makeConnection(transport)

        clock.advance(120)
        self.assertEqual(results, [True])
        assert_clock_idle(self, clock)
开发者ID:nand0p,项目名称:buildbot,代码行数:22,代码来源:test_util_hangcheck.py

示例9: _timeoutTest

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import protocol [as 别名]
 def _timeoutTest(self, onDone, clientFactory):
     """
     Connect the clientFactory, and check the timeout on the request.
     """
     clock = task.Clock()
     client = clientFactory.buildProtocol(
         address.IPv4Address('TCP', 'example.net', 25))
     client.callLater = clock.callLater
     t = StringTransport()
     client.makeConnection(t)
     t.protocol = client
     def check(ign):
         self.assertEquals(clock.seconds(), 0.5)
     d = self.assertFailure(onDone, smtp.SMTPTimeoutError
         ).addCallback(check)
     # The first call should not trigger the timeout
     clock.advance(0.1)
     # But this one should
     clock.advance(0.4)
     return d
开发者ID:Almad,项目名称:twisted,代码行数:22,代码来源:test_smtp.py

示例10: test_disconnect_forwarded

# 需要导入模块: from twisted.test.proto_helpers import StringTransport [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransport import protocol [as 别名]
    def test_disconnect_forwarded(self):
        """
        If the connection is closed, the underlying protocol is informed.
        """
        clock = Clock()
        wrapped_protocol = AccumulatingProtocol()
        protocol = HangCheckProtocol(wrapped_protocol, reactor=clock)
        transport = StringTransport()

        transport.protocol = protocol
        protocol.makeConnection(transport)
        reason = ConnectionDone("Bye.")
        protocol.connectionLost(
            Failure(reason)
        )

        self.assertTrue(wrapped_protocol.closed)
        self.assertEqual(
            wrapped_protocol.closedReason.value,
            reason,
        )
开发者ID:nand0p,项目名称:buildbot,代码行数:23,代码来源:test_util_hangcheck.py


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