summaryrefslogtreecommitdiff
path: root/tests/auth_tests/test_forms.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-03-20 12:24:51 +0200
committerTim Graham <timograham@gmail.com>2016-03-21 12:32:42 -0400
commitefa9539787dbdd06cd2169023edcf7db3e2ff0c4 (patch)
tree73f9bc71e4bf30d031b8fb2393661ee45f30697d /tests/auth_tests/test_forms.py
parent2b31f14d89cb144fad10389824828e90fd1a2dcc (diff)
Fixed #26381 -- Made UserCreationForm reusable with custom user models that define USERNAME_FIELD.
Diffstat (limited to 'tests/auth_tests/test_forms.py')
-rw-r--r--tests/auth_tests/test_forms.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py
index 6172c44783..f43a814c88 100644
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -20,7 +20,7 @@ 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 ExtensionUser
+from .models.custom_user import CustomUser, ExtensionUser
from .settings import AUTH_TEMPLATES
@@ -139,6 +139,21 @@ class UserCreationFormTest(TestDataMixin, TestCase):
form = CustomUserCreationForm(data)
self.assertTrue(form.is_valid())
+ def test_custom_form_with_different_username_field(self):
+ class CustomUserCreationForm(UserCreationForm):
+ class Meta(UserCreationForm.Meta):
+ model = CustomUser
+ fields = ('email', 'date_of_birth')
+
+ data = {
+ 'email': 'test@client222.com',
+ 'password1': 'testclient',
+ 'password2': 'testclient',
+ 'date_of_birth': '1988-02-24',
+ }
+ form = CustomUserCreationForm(data)
+ self.assertTrue(form.is_valid())
+
def test_password_whitespace_not_stripped(self):
data = {
'username': 'testuser',