def test_cancel(self):
        """
        When cancelling the L{Deferred} returned by L{client.readBody}, the
        connection to the server will be aborted.
        """
        response = DummyResponse()
        deferred = client.readBody(response)
        deferred.cancel()
        self.failureResultOf(deferred, defer.CancelledError)
        self.assertTrue(response.transport.aborting)

        When cancelling the L{Deferred} returned by L{client.readBody}, the
        connection to the server will be aborted.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_agent.py