diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
index 2513380286..b713cb1321 100644
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -20,6 +20,7 @@ from django.forms.utils import ErrorList
from django.http import QueryDict
from django.template import Context, Template
from django.test import SimpleTestCase
+from django.test.utils import override_settings
from django.utils.datastructures import MultiValueDict
from django.utils.safestring import mark_safe
@@ -1248,6 +1249,24 @@ value="Should escape < & > and <script>alert('xss')<
self.assertEqual(f.errors, error_dict)
f.as_table()
self.assertEqual(f.errors, error_dict)
+ self.assertHTMLEqual(
+ f.as_table(),
+ '
- Form error
'
+ '- (Hidden field hidden_input) This field is required.
'
+ ' |
',
+ )
+ self.assertHTMLEqual(
+ f.as_ul(),
+ '- Form error
'
+ '- (Hidden field hidden_input) This field is required.
'
+ '',
+ )
+ self.assertHTMLEqual(
+ f.as_p(),
+ '- Form error
'
+ '- (Hidden field hidden_input) This field is required.
'
+ '',
+ )
def test_dynamic_construction(self):
# It's possible to construct a Form dynamically by adding to the self.fields
@@ -3637,6 +3656,23 @@ Password:
self.assertIsInstance(field_copy, CustomCharField)
self.assertIsNot(field_copy.error_messages, field.error_messages)
+ def test_label_does_not_include_new_line(self):
+ form = Person()
+ field = form['first_name']
+ self.assertEqual(
+ field.label_tag(),
+ '',
+ )
+
+ @override_settings(USE_THOUSAND_SEPARATOR=True)
+ def test_label_attrs_not_localized(self):
+ form = Person()
+ field = form['first_name']
+ self.assertHTMLEqual(
+ field.label_tag(attrs={'number': 9999}),
+ '',
+ )
+
class CustomRenderer(DjangoTemplates):
pass