test_protocol.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:txdarn 作者: markrwilliams 项目源码 文件源码
def test_connectionLost_clientClose(self):
        '''If connectionLost is called because the client closed the
        connection, then this connection has disappeared suddenly.
        Consequently, the protocol's terminationDeferred errbacks with
        the provided reason, the timeout clock is stopped, and the
        session machine learns about the lost connection.

        '''
        erroredDeferred = self.protocol.terminationDeferred

        def trapConnectionDone(failure):
            failure.trap(error.ConnectionDone)

        erroredDeferred.addErrback(trapConnectionDone)

        self.protocol.connectionLost(connectionDone)

        self.assertEqual(self.timeoutClockRecorder.stopCalls, 1)
        self.assertEqual(self.sessionMachineRecorder.connectionsLostReasons,
                         [connectionDone])
        self.assertIsNone(self.protocol.sessionMachine)

        return erroredDeferred
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号