def test_challengerRaisesException(self):
        """
        When a challenger's
        L{getChallenge<IChallengeResponse.getChallenge>} method raises
        any exception, a C{NO} response is sent.
        """

        @implementer(IChallengeResponse)
        class ValueErrorAuthChallenge(object):
            message = b"A challenge failure"

            def getChallenge(self):
                raise ValueError(self.message)


            def setResponse(self, response):
                """
                Never called.

                @param response: See L{IChallengeResponse.setResponse}
                """


            def moreChallenges(self):
                """
                Never called.
                """

        @implementer(IClientAuthentication)
        class ValueErrorAuthenticator(object):

            def getName(self):
                return b"ERROR"

            def challengeResponse(self, secret, chal):
                return b"IGNORED"

        bad = ValueErrorAuthChallenge()
        verifyObject(IChallengeResponse, bad)

        self.server.challengers[b'ERROR'] = ValueErrorAuthChallenge
        self.client.registerAuthenticator(ValueErrorAuthenticator())

        def auth():
            return self.client.authenticate(b'secret')

        d = self.connected.addCallback(strip(auth))
        d.addErrback(self.assertClientFailureMessage,
                     ("Server error: "
                      + str(ValueErrorAuthChallenge.message)).encode('ascii'))
        d.addCallbacks(self._cbStopClient, self._ebGeneral)

        return defer.gatherResults([d, self.loopback()])

        When a challenger's
        L{getChallenge<IChallengeResponse.getChallenge>} method raises
        any exception, a C{NO} response is sent.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_imap.py