diff options
| author | David Sanders <dsanders11@ucsbalum.com> | 2021-05-18 21:05:04 -0700 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-05-19 20:34:57 +0200 |
| commit | 536c155e67fd82ef23975919bd55ccec966f96f8 (patch) | |
| tree | b67a337cf44971bccea092eda6ba57553fa620ed /tests/auth_tests/test_forms.py | |
| parent | fa4e963ee7e6876581b5432363603571839ba00c (diff) | |
Fixed #32765 -- Removed "for" HTML attribute from ReadOnlyPasswordHashWidget.
ReadOnlyPasswordHashWidget doesn't have any labelable elements.
Diffstat (limited to 'tests/auth_tests/test_forms.py')
| -rw-r--r-- | tests/auth_tests/test_forms.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index 7a731bedc8..76b0eb7f3c 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -13,6 +13,7 @@ from django.contrib.sites.models import Site from django.core import mail from django.core.exceptions import ValidationError from django.core.mail import EmailMultiAlternatives +from django.forms import forms from django.forms.fields import CharField, Field, IntegerField from django.test import SimpleTestCase, TestCase, override_settings from django.utils import translation @@ -1025,6 +1026,18 @@ class ReadOnlyPasswordHashTest(SimpleTestCase): self.assertIs(field.disabled, True) self.assertFalse(field.has_changed('aaa', 'bbb')) + def test_label(self): + """ + ReadOnlyPasswordHashWidget doesn't contain a for attribute in the + <label> because it doesn't have any labelable elements. + """ + class TestForm(forms.Form): + hash_field = ReadOnlyPasswordHashField() + + bound_field = TestForm()['hash_field'] + self.assertEqual(bound_field.field.widget.id_for_label('id'), None) + self.assertEqual(bound_field.label_tag(), '<label>Hash field:</label>') + class AdminPasswordChangeFormTest(TestDataMixin, TestCase): |
