def test_cancelsOnConnectionLost(self):
app = self.app
request = requestMock(b"/")
handler_d = Deferred()
@app.route("/")
def root(request):
return handler_d
d = _render(self.kr, request)
self.assertNotFired(d)
request.connectionLost(ConnectionLost())
handler_d.addErrback(lambda f: f.trap(CancelledError))
d.addErrback(lambda f: f.trap(ConnectionLost))
d.addCallback(lambda _: handler_d)
self.assertFired(d)
评论列表
文章目录