def test_quiescentCallbackThrows(self):
        """
        If C{quiescentCallback} throws an exception, the error is logged and
        protocol is disconnected.
        """
        def callback(p):
            raise ZeroDivisionError()

        logObserver = EventLoggingObserver.createWithCleanup(
            self,
            globalLogPublisher
        )

        transport = StringTransport()
        protocol = HTTP11ClientProtocol(callback)
        protocol.makeConnection(transport)

        requestDeferred = protocol.request(
            Request(b'GET', b'/', _boringHeaders, None, persistent=True))
        protocol.dataReceived(
            b"HTTP/1.1 200 OK\r\n"
            b"Content-length: 0\r\n"
            b"\r\n")

        result = []
        requestDeferred.addCallback(result.append)
        response = result[0]
        bodyProtocol = AccumulatingProtocol()
        response.deliverBody(bodyProtocol)
        bodyProtocol.closedReason.trap(ResponseDone)

        self.assertEquals(1, len(logObserver))
        event = logObserver[0]
        f = event["log_failure"]
        self.assertIsInstance(f.value, ZeroDivisionError)

        self.flushLoggedErrors(ZeroDivisionError)
        self.assertTrue(transport.disconnecting)

        If C{quiescentCallback} throws an exception, the error is logged and
        protocol is disconnected.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_newclient.py