'Unexpected exceptions from the login handler are caught'

def test_loginError(self):

    def _fake_loginhandler(*args, **kwargs):
        return defer.fail(AssertionError('test    exception'))
    self.serverProtocol.portal.login = _fake_loginhandler
    d = self.client.queueStringCommand('USER    foo')
    self.assertCommandFailed('PASS    bar', ['550    Requested    action    not    taken:    internal    server    error'], chainDeferred=d)
    @d.addCallback
    def checkLogs(result):
        logs = self.flushLoggedErrors()
        self.assertEqual(1, len(logs))
        self.assertIsInstance(logs[0].value, AssertionError)
    return d
