diff options
| author | Berker Peksag <berker.peksag@gmail.com> | 2016-08-24 20:20:12 +0300 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-24 13:23:50 -0400 |
| commit | c4ee93128f1880c3993cf07619ff4e0524920a8e (patch) | |
| tree | 78f653b4e232a068e0d4810bdbb18188b5ad4525 /tests/auth_tests/test_forms.py | |
| parent | 6f006f40f78649c20c72c75c8159e164de9c7b6c (diff) | |
[1.10.x] Fixed #27111 -- Fixed KeyError if USERNAME_FIELD isn't in UserCreationForm.fields.
Backport of 3c18f8a3d2f61669493f9ff2015ddc027eada3d6 from master
Diffstat (limited to 'tests/auth_tests/test_forms.py')
| -rw-r--r-- | tests/auth_tests/test_forms.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index fe22d1e20b..64c095bf2a 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -22,7 +22,9 @@ from django.utils.encoding import force_text from django.utils.text import capfirst from django.utils.translation import ugettext as _ -from .models.custom_user import CustomUser, ExtensionUser +from .models.custom_user import ( + CustomUser, CustomUserWithoutIsActiveField, ExtensionUser, +) from .settings import AUTH_TEMPLATES @@ -208,6 +210,20 @@ class UserCreationFormTest(TestDataMixin, TestCase): form = CustomUserCreationForm(data) self.assertTrue(form.is_valid()) + def test_custom_form_hidden_username_field(self): + class CustomUserCreationForm(UserCreationForm): + class Meta(UserCreationForm.Meta): + model = CustomUserWithoutIsActiveField + fields = ('email',) # without USERNAME_FIELD + + data = { + 'email': 'testclient@example.com', + 'password1': 'testclient', + 'password2': 'testclient', + } + form = CustomUserCreationForm(data) + self.assertTrue(form.is_valid()) + def test_password_whitespace_not_stripped(self): data = { 'username': 'testuser', |
