summaryrefslogtreecommitdiff
path: root/tests/auth_tests/test_forms.py
diff options
context:
space:
mode:
authorLucas Connors <lucas.revolutiontech@gmail.com>2017-08-17 14:08:56 -0700
committerTim Graham <timograham@gmail.com>2017-10-20 11:13:26 -0400
commit5ceaf14686ce626404afb6a5fbd3d8286410bf13 (patch)
tree194cbda5c0c2c4ce866727aeed94544eb556a051 /tests/auth_tests/test_forms.py
parentd2333912085fc3bd827295f2bc8253d6723c242b (diff)
Fixed #27515 -- Made AuthenticationForm's username field use the max_length from the model field.
Thanks Ramin Farajpour Cami for the report.
Diffstat (limited to 'tests/auth_tests/test_forms.py')
-rw-r--r--tests/auth_tests/test_forms.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py
index f7d0e71ea9..f15aef37e3 100644
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -377,6 +377,19 @@ class AuthenticationFormTest(TestDataMixin, TestCase):
self.assertTrue(form.is_valid())
self.assertEqual(form.non_field_errors(), [])
+ @override_settings(AUTH_USER_MODEL='auth_tests.CustomEmailField')
+ def test_username_field_max_length_matches_user_model(self):
+ self.assertEqual(CustomEmailField._meta.get_field('username').max_length, 255)
+ data = {
+ 'username': 'u' * 255,
+ 'password': 'pwd',
+ 'email': 'test@example.com',
+ }
+ CustomEmailField.objects.create_user(**data)
+ form = AuthenticationForm(None, data)
+ self.assertEqual(form.fields['username'].max_length, 255)
+ self.assertEqual(form.errors, {})
+
@override_settings(AUTH_USER_MODEL='auth_tests.IntegerUsernameUser')
def test_username_field_max_length_defaults_to_254(self):
self.assertIsNone(IntegerUsernameUser._meta.get_field('username').max_length)