summaryrefslogtreecommitdiff
path: root/tests/auth_tests/test_forms.py
diff options
context:
space:
mode:
authorpmisteli <p.d.misteli@student.tudelft.nl>2019-03-24 19:53:31 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-03-29 15:24:44 +0100
commit9410db968388820e43aa453a640dd4720fff0c0f (patch)
tree8d718d612cd7dd1b3c9f37c9fd1b342b8e5eb713 /tests/auth_tests/test_forms.py
parent9aa56cb0d5dede7fc176a46c745dfd3dacdad773 (diff)
Fixed #30236 -- Made UsernameField render with autocapitalize="none" HTML attribute.
This prevents automatic capitalization, which is the default behavior in some browsers.
Diffstat (limited to 'tests/auth_tests/test_forms.py')
-rw-r--r--tests/auth_tests/test_forms.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py
index 825138755d..e12cf0161f 100644
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -261,6 +261,10 @@ class UserCreationFormTest(TestDataMixin, TestCase):
['The password is too similar to the first name.'],
)
+ def test_username_field_autocapitalize_none(self):
+ form = UserCreationForm()
+ self.assertEqual(form.fields['username'].widget.attrs.get('autocapitalize'), 'none')
+
# To verify that the login form rejects inactive users, use an authentication
# backend that allows them.
@@ -439,6 +443,10 @@ class AuthenticationFormTest(TestDataMixin, TestCase):
username_field = User._meta.get_field(User.USERNAME_FIELD)
self.assertEqual(form.fields['username'].label, capfirst(username_field.verbose_name))
+ def test_username_field_autocapitalize_none(self):
+ form = AuthenticationForm()
+ self.assertEqual(form.fields['username'].widget.attrs.get('autocapitalize'), 'none')
+
def test_username_field_label_empty_string(self):
class CustomAuthenticationForm(AuthenticationForm):
@@ -728,6 +736,10 @@ class UserChangeFormTest(TestDataMixin, TestCase):
form = UserChangeFormWithoutPassword()
self.assertNotIn('password', form.fields)
+ def test_username_field_autocapitalize_none(self):
+ form = UserChangeForm()
+ self.assertEqual(form.fields['username'].widget.attrs.get('autocapitalize'), 'none')
+
@override_settings(TEMPLATES=AUTH_TEMPLATES)
class PasswordResetFormTest(TestDataMixin, TestCase):