def test_unexpectedLoginFailure(self):
        """
        If the L{Deferred} returned by L{Portal.login} fires with an
        exception of any type other than L{UnauthorizedLogin}, the exception
        is logged and the client is informed that the authentication attempt
        has failed.
        """
        loginArgs = []
        self.server.portal = self.portalFactory(loginArgs)

        self.server.dataReceived(b'EHLO\r\n')
        self.transport.clear()

        self.assertServerResponse(
            b'AUTH LOGIN ' + base64.b64encode(b'username').strip() + b'\r\n',
            [b'334 ' + base64.b64encode(b'Password\0').strip()])
        self.assertServerResponse(
            base64.b64encode(b'password').strip() + b'\r\n',
            [])

        d, credentials, mind, interfaces = loginArgs.pop()
        d.errback(RuntimeError("Something wrong with the server"))

        self.assertEqual(
            b'451 Requested action aborted: local error in processing\r\n',
            self.transport.value())

        self.assertEqual(len(self.flushLoggedErrors(RuntimeError)), 1)

        If the L{Deferred} returned by L{Portal.login} fires with an
        exception of any type other than L{UnauthorizedLogin}, the exception
        is logged and the client is informed that the authentication attempt
        has failed.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_smtp.py