def test_noTimeoutIfConnectionLost(self):
"""
When a L{H2Connection} loses its connection it cancels its timeout.
"""
frameFactory = FrameFactory()
frames = buildRequestFrames(self.getRequestHeaders, [], frameFactory)
initialData = frameFactory.clientConnectionPreface()
initialData += b''.join(f.serialize() for f in frames)
reactor, conn, transport = self.initiateH2Connection(
initialData, requestFactory=DummyProducerHandler,
)
sentData = transport.value()
oldCallCount = len(reactor.getDelayedCalls())
# Now lose the connection.
conn.connectionLost("reason")
# There should be one fewer call than there was.
currentCallCount = len(reactor.getDelayedCalls())
self.assertEqual(oldCallCount - 1, currentCallCount)
# Advancing the clock should do nothing.
reactor.advance(101)
self.assertEqual(transport.value(), sentData)
评论列表
文章目录