From 182d25eb7a227206746bfa30aab13aaa34d1de84 Mon Sep 17 00:00:00 2001
From: Mariusz Felisiak
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="custom
\n' - '' - '