def test_finishCleansConnection(self):
        """
        L{http.Request.finish} will notify the channel that it is finished, and
        will put the transport back in the producing state so that the reactor
        can close the connection.
        """
        factory = http.HTTPFactory()
        factory.timeOut = None
        factory._logDateTime = "sometime"
        factory._logDateTimeCall = True
        factory.startFactory()
        factory.logFile = BytesIO()
        proto = factory.buildProtocol(None)
        proto._channel._optimisticEagerReadSize = 0

        val = [
            b"GET /path HTTP/1.1\r\n",
            b"\r\n\r\n"
        ]

        trans = StringTransport()
        proto.makeConnection(trans)

        self.assertEqual(trans.producerState, 'producing')

        for x in val:
            proto.dataReceived(x)

        proto.dataReceived(b'GET ') # just a few extra bytes to exhaust the
                                    # optimistic buffer size
        self.assertEqual(trans.producerState, 'paused')
        proto._channel.requests[0].finish()
        self.assertEqual(trans.producerState, 'producing')

        L{http.Request.finish} will notify the channel that it is finished, and
        will put the transport back in the producing state so that the reactor
        can close the connection.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_http.py