'logging in fails with an inactive user'

def test_login_deactivated_mirror_dummy(self):

    user_profile = self.example_user('hamlet')
    user_profile.is_mirror_dummy = True
    user_profile.save()
    password = initial_password(user_profile.email)
    request = mock.MagicMock()
    request.get_host.return_value = 'testserver'
    form = OurAuthenticationForm(request, data={'username': user_profile.email, 'password': password})
    with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.EmailAuthBackend',)):
        self.assertTrue(form.is_valid())
    do_deactivate_user(user_profile)
    user_profile.save()
    form = OurAuthenticationForm(request, data={'username': user_profile.email, 'password': password})
    with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.EmailAuthBackend',)):
        self.assertFalse(form.is_valid())
        self.assertIn('Please    enter    a    correct    email', str(form.errors))
    user_profile.is_mirror_dummy = False
    user_profile.save()
    form = OurAuthenticationForm(request, data={'username': user_profile.email, 'password': password})
    with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.EmailAuthBackend',)):
        self.assertFalse(form.is_valid())
        self.assertIn('your    account    has    been    deactivated', str(form.errors))
