diff options
| author | Gavin Wahl <gwahl@fusionbox.com> | 2016-02-18 17:58:30 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-09-12 20:30:34 -0400 |
| commit | f0f3de3c96694fd3602541fa6074930667509ac8 (patch) | |
| tree | 5796a4c6d4fbca35d29d3faa28c041324723d481 /tests/auth_tests/test_forms.py | |
| parent | 4b9330ccc04575f9e5126529ec355a450d12e77c (diff) | |
Fixed #23155 -- Added request argument to user_login_failed signal.
Diffstat (limited to 'tests/auth_tests/test_forms.py')
| -rw-r--r-- | tests/auth_tests/test_forms.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index 19f0f4521c..c0e2961424 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -12,6 +12,7 @@ from django.contrib.auth.forms import ( SetPasswordForm, UserChangeForm, UserCreationForm, ) from django.contrib.auth.models import User +from django.contrib.auth.signals import user_login_failed from django.contrib.sites.models import Site from django.core import mail from django.core.mail import EmailMultiAlternatives @@ -279,6 +280,24 @@ class AuthenticationFormTest(TestDataMixin, TestCase): self.assertFalse(form.is_valid()) self.assertEqual(form.non_field_errors(), [force_text(form.error_messages['inactive'])]) + def test_login_failed(self): + signal_calls = [] + + def signal_handler(**kwargs): + signal_calls.append(kwargs) + + user_login_failed.connect(signal_handler) + fake_request = object() + try: + form = AuthenticationForm(fake_request, { + 'username': 'testclient', + 'password': 'incorrect', + }) + self.assertFalse(form.is_valid()) + self.assertIs(signal_calls[0]['request'], fake_request) + finally: + user_login_failed.disconnect(signal_handler) + def test_inactive_user_i18n(self): with self.settings(USE_I18N=True), translation.override('pt-br', deactivate=True): # The user is inactive. |
