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:20:12 -0400 |
| commit | 3c18f8a3d2f61669493f9ff2015ddc027eada3d6 (patch) | |
| tree | 0404984ebc4f2a04dcae05eb1c65afa6f186b6da /tests/auth_tests/test_forms.py | |
| parent | 9aaeec337e217109208672d8fe47eeb49ca492b5 (diff) | |
Fixed #27111 -- Fixed KeyError if USERNAME_FIELD isn't in UserCreationForm.fields.
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 707d5b87ad..dde639dc01 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 .models.with_integer_username import IntegerUsernameUser from .settings import AUTH_TEMPLATES @@ -209,6 +211,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', |
