From 966ecdd482167f3f6b08b00f484936c837751cb9 Mon Sep 17 00:00:00 2001 From: Gregor Jerše Date: Thu, 1 Jun 2023 16:44:57 +0200 Subject: Fixed #32819 -- Established relationship between form fields and their help text. Thanks Nimra for the initial patch. Thanks Natalia Bidart, Thibaud Colas, David Smith, and Mariusz Felisiak for reviews. --- tests/admin_inlines/tests.py | 2 +- tests/forms_tests/tests/test_forms.py | 70 ++++++++++++++++++++++++++++++++++- tests/model_forms/tests.py | 3 +- 3 files changed, 71 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py index 0be8d665d1..9533cc9af3 100644 --- a/tests/admin_inlines/tests.py +++ b/tests/admin_inlines/tests.py @@ -452,7 +452,7 @@ class TestInline(TestDataMixin, TestCase): self.assertContains( response, '', + 'maxlength="100" aria-describedby="id_-1-0-name_helptext">', html=True, ) self.assertContains( diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index c283ab20ef..99a38eedcb 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -3016,6 +3016,72 @@ Options: ' + "
" + '' + '
Wählen Sie mit Bedacht.' + '
', + ) + self.assertHTMLEqual( + p.as_ul(), + '
  • ' + 'e.g., user@example.com' + "
  • " + '' + '' + 'Wählen Sie mit Bedacht.' + "
  • ", + ) + self.assertHTMLEqual( + p.as_p(), + '

    ' + 'e.g., user@example.com' + "

    " + '' + '' + 'Wählen Sie mit Bedacht.' + "

    ", + ) + self.assertHTMLEqual( + p.as_table(), + '' + '
    ' + 'e.g., user@example.com' + "" + '' + '
    ' + 'Wählen Sie mit Bedacht.' + "", + ) + def test_subclassing_forms(self): # You can subclass a Form to add fields. The resulting form subclass will have # all of the fields of the parent Form, plus whichever fields you define in the @@ -4796,7 +4862,7 @@ class TemplateTests(SimpleTestCase): "
    " '

    ' '

    " + 'aria-describedby="id_username_helptext" required>

    ' '

    ' '

    ' '

    ' @@ -4833,7 +4899,7 @@ class TemplateTests(SimpleTestCase): "" '

    Username:' '

    " + 'aria-describedby="id_username_helptext" required>

    ' '

    Password1:' '

    ' '

    Password2:' diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index b807e90ef9..d1716ce201 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -958,7 +958,8 @@ class TestFieldOverridesByFormMeta(SimpleTestCase): ) self.assertHTMLEqual( str(form["slug"]), - '', + '', ) def test_label_overrides(self): -- cgit v1.3