From 4c60c3edff4312303e1021fca47ed52c2152d285 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 7 Jan 2022 07:46:55 +0000 Subject: Fixed #33419 -- Restored marking forms.Field.help_text as HTML safe. Regression in 456466d932830b096d39806e291fe23ec5ed38d5. Thanks Matt Westcott for the report. --- tests/forms_tests/tests/test_forms.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests/forms_tests') diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 5c653fb492..aa47481998 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -2326,6 +2326,41 @@ Password: """ ) + def test_help_text_html_safe(self): + """help_text should not be escaped.""" + class UserRegistration(Form): + username = CharField(max_length=10, help_text='e.g., user@example.com') + password = CharField( + widget=PasswordInput, + help_text='Help text is escaped.', + ) + + p = UserRegistration(auto_id=False) + self.assertHTMLEqual( + p.as_ul(), + '
  • Username: ' + 'e.g., user@example.com
  • ' + '
  • Password: ' + 'Help text is escaped.
  • ' + ) + self.assertHTMLEqual( + p.as_p(), + '

    Username: ' + 'e.g., user@example.com

    ' + '

    Password: ' + 'Help text is escaped.

    ' + ) + self.assertHTMLEqual( + p.as_table(), + 'Username:' + '
    ' + 'e.g., user@example.com' + 'Password:' + '
    ' + 'Help text is escaped.' + '' + ) + 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 -- cgit v1.3