def test_unhandledCredentials(self):
        """
        A challenger that causes the login to fail
        L{UnhandledCredentials} results in an C{NO} response.

        @return: A L{Deferred} that fires when the authorization has
            failed.
        """
        realm = TestRealm()
        portal = Portal(realm)
        # This portal has no checkers, so all logins will fail with
        # UnhandledCredentials
        self.server.portal = portal

        self.server.challengers[b'LOGIN'] = loginCred = imap4.LOGINCredentials

        verifyClass(IChallengeResponse, loginCred)

        cAuth = imap4.LOGINAuthenticator(b'testuser')
        self.client.registerAuthenticator(cAuth)

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

        d1 = self.connected.addCallback(strip(auth))
        d1.addErrback(self.assertClientFailureMessage,
                      b"Authentication failed: server misconfigured")
        d1.addCallbacks(self._cbStopClient, self._ebGeneral)
        d = defer.gatherResults([self.loopback(), d1])
        return d

        A challenger that causes the login to fail
        L{UnhandledCredentials} results in an C{NO} response.

        @return: A L{Deferred} that fires when the authorization has
            failed.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_imap.py