def test_unexpectedLoginError(self):
        """
        Any unexpected failure from L{Portal.login} results in a 500 response
        code and causes the failure to be logged.
        """
        logObserver = EventLoggingObserver.createWithCleanup(
            self,
            globalLogPublisher
        )
        class UnexpectedException(Exception):
            pass

        class BrokenChecker(object):
            credentialInterfaces = (IUsernamePassword,)

            def requestAvatarId(self, credentials):
                raise UnexpectedException()

        self.portal.registerChecker(BrokenChecker())
        self.credentialFactories.append(BasicCredentialFactory('example.com'))
        request = self.makeRequest([self.childName])
        child = self._authorizedBasicLogin(request)
        request.render(child)
        self.assertEqual(request.responseCode, 500)
        self.assertEquals(1, len(logObserver))
        self.assertIsInstance(
            logObserver[0]["log_failure"].value,
            UnexpectedException
        )
        self.assertEqual(len(self.flushLoggedErrors(UnexpectedException)), 1)

        Any unexpected failure from L{Portal.login} results in a 500 response
        code and causes the failure to be logged.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_httpauth.py