From 182d25eb7a227206746bfa30aab13aaa34d1de84 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 10 Jan 2023 13:43:21 +0100 Subject: Refs #31026 -- Removed BaseForm._html_output() per deprecation timeline. --- tests/forms_tests/tests/test_deprecation_forms.py | 135 +--------------------- 1 file changed, 1 insertion(+), 134 deletions(-) (limited to 'tests/forms_tests') diff --git a/tests/forms_tests/tests/test_deprecation_forms.py b/tests/forms_tests/tests/test_deprecation_forms.py index 2a4fb6b0e1..dbc751bae8 100644 --- a/tests/forms_tests/tests/test_deprecation_forms.py +++ b/tests/forms_tests/tests/test_deprecation_forms.py @@ -1,11 +1,9 @@ # RemovedInDjango50 -from django.forms import CharField, EmailField, Form, HiddenInput +from django.forms import CharField, EmailField, Form from django.forms.utils import ErrorList from django.test import SimpleTestCase, ignore_warnings from django.utils.deprecation import RemovedInDjango50Warning -from .test_forms import Person - class DivErrorList(ErrorList): def __str__(self): @@ -20,21 +18,6 @@ class DivErrorList(ErrorList): class DeprecationTests(SimpleTestCase): - def test_deprecation_warning_html_output(self): - msg = ( - "django.forms.BaseForm._html_output() is deprecated. Please use " - ".render() and .get_context() instead." - ) - with self.assertRaisesMessage(RemovedInDjango50Warning, msg): - form = Person() - form._html_output( - normal_row='

', - error_row="%s", - row_ender="

", - help_text_html=" %s", - errors_on_separate_row=True, - ) - def test_deprecation_warning_error_list(self): class EmailForm(Form): email = EmailField() @@ -70,119 +53,3 @@ class DeprecatedTests(SimpleTestCase): '
This field is required.
' '

Comment:

', ) - - def test_field_name(self): - """#5749 - `field_name` may be used as a key in _html_output().""" - - class SomeForm(Form): - some_field = CharField() - - def as_p(self): - return self._html_output( - normal_row='

', - error_row="%s", - row_ender="

", - help_text_html=" %s", - errors_on_separate_row=True, - ) - - form = SomeForm() - self.assertHTMLEqual(form.as_p(), '

') - - def test_field_without_css_classes(self): - """ - `css_classes` may be used as a key in _html_output() (empty classes). - """ - - class SomeForm(Form): - some_field = CharField() - - def as_p(self): - return self._html_output( - normal_row='

', - error_row="%s", - row_ender="

", - help_text_html=" %s", - errors_on_separate_row=True, - ) - - form = SomeForm() - self.assertHTMLEqual(form.as_p(), '

') - - def test_field_with_css_class(self): - """ - `css_classes` may be used as a key in _html_output() (class comes - from required_css_class in this case). - """ - - class SomeForm(Form): - some_field = CharField() - required_css_class = "foo" - - def as_p(self): - return self._html_output( - normal_row='

', - error_row="%s", - row_ender="

", - help_text_html=" %s", - errors_on_separate_row=True, - ) - - form = SomeForm() - self.assertHTMLEqual(form.as_p(), '

') - - def test_field_name_with_hidden_input(self): - """ - BaseForm._html_output() should merge all the hidden input fields and - put them in the last row. - """ - - class SomeForm(Form): - hidden1 = CharField(widget=HiddenInput) - custom = CharField() - hidden2 = CharField(widget=HiddenInput) - - def as_p(self): - return self._html_output( - normal_row="%(field)s %(field_name)s

", - error_row="%s", - row_ender="

", - help_text_html=" %s", - errors_on_separate_row=True, - ) - - form = SomeForm() - self.assertHTMLEqual( - form.as_p(), - '

custom' - '' - '

', - ) - - def test_field_name_with_hidden_input_and_non_matching_row_ender(self): - """ - BaseForm._html_output() should merge all the hidden input fields and - put them in the last row ended with the specific row ender. - """ - - class SomeForm(Form): - hidden1 = CharField(widget=HiddenInput) - custom = CharField() - hidden2 = CharField(widget=HiddenInput) - - def as_p(self): - return self._html_output( - normal_row="%(field)s %(field_name)s

", - error_row="%s", - row_ender="

", - help_text_html=" %s", - errors_on_separate_row=True, - ) - - form = SomeForm() - self.assertHTMLEqual( - form.as_p(), - '

custom

\n' - '' - '

', - ) -- cgit v1.3