diff options
| author | François Freitag <mail@franek.fr> | 2020-02-12 14:48:49 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-28 10:49:00 +0200 |
| commit | 9ef4a18dbe71f538a9ef8c39111ae2f0b62eb90b (patch) | |
| tree | 0016b13a357af2f642483bdd168d6f83190f33bb /tests/auth_tests/test_forms.py | |
| parent | 2788de95e375cccd03a3dfd161fc92b7d6df6024 (diff) | |
Changed django.forms.ValidationError imports to django.core.exceptions.ValidationError.
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'tests/auth_tests/test_forms.py')
| -rw-r--r-- | tests/auth_tests/test_forms.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index 4e5f8e3094..88b4b32667 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -2,7 +2,6 @@ import datetime import re from unittest import mock -from django import forms from django.contrib.auth.forms import ( AdminPasswordChangeForm, AuthenticationForm, PasswordChangeForm, PasswordResetForm, ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget, @@ -12,6 +11,7 @@ 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.exceptions import ValidationError from django.core.mail import EmailMultiAlternatives from django.forms.fields import CharField, Field, IntegerField from django.test import SimpleTestCase, TestCase, override_settings @@ -372,13 +372,13 @@ class AuthenticationFormTest(TestDataMixin, TestCase): form = AuthenticationFormWithInactiveUsersOkay(None, data) self.assertTrue(form.is_valid()) - # If we want to disallow some logins according to custom logic, - # we should raise a django.forms.ValidationError in the form. + # Raise a ValidationError in the form to disallow some logins according + # to custom logic. class PickyAuthenticationForm(AuthenticationForm): def confirm_login_allowed(self, user): if user.username == "inactive": - raise forms.ValidationError("This user is disallowed.") - raise forms.ValidationError("Sorry, nobody's allowed in.") + raise ValidationError("This user is disallowed.") + raise ValidationError("Sorry, nobody's allowed in.") form = PickyAuthenticationForm(None, data) self.assertFalse(form.is_valid()) @@ -496,7 +496,7 @@ class AuthenticationFormTest(TestDataMixin, TestCase): def test_get_invalid_login_error(self): error = AuthenticationForm().get_invalid_login_error() - self.assertIsInstance(error, forms.ValidationError) + self.assertIsInstance(error, ValidationError) self.assertEqual( error.message, 'Please enter a correct %(username)s and password. Note that both ' |
