Refs #19130 -- Added a test for AuthenticationForm.username max_length.

This will be a more useful regression test after refs #27515.
This commit is contained in:
Lucas Connors 2017-10-20 11:09:03 -04:00 committed by Tim Graham
parent 5114669f72
commit d233391208
1 changed files with 12 additions and 0 deletions

View File

@ -377,6 +377,18 @@ class AuthenticationFormTest(TestDataMixin, TestCase):
self.assertTrue(form.is_valid())
self.assertEqual(form.non_field_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)
data = {
'username': '0123456',
'password': 'password',
}
IntegerUsernameUser.objects.create_user(**data)
form = AuthenticationForm(None, data)
self.assertEqual(form.fields['username'].max_length, 254)
self.assertEqual(form.errors, {})
def test_username_field_label(self):
class CustomAuthenticationForm(AuthenticationForm):