1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Refs #32339 -- Added use_fieldset to Widget.

This commit is contained in:
David
2022-01-13 23:08:38 +00:00
committed by Carlton Gibson
parent 04ad0f26ba
commit c8459708a7
28 changed files with 489 additions and 22 deletions

View File

@@ -1,17 +1,32 @@
from django.forms.widgets import NumberInput
from django.forms import CharField, Form, NumberInput
from django.test import override_settings
from .base import WidgetTest
class NumberInputTests(WidgetTest):
widget = NumberInput(attrs={"max": 12345, "min": 1234, "step": 9999})
@override_settings(USE_THOUSAND_SEPARATOR=True)
def test_attrs_not_localized(self):
widget = NumberInput(attrs={"max": 12345, "min": 1234, "step": 9999})
self.check_html(
widget,
self.widget,
"name",
"value",
'<input type="number" name="name" value="value" max="12345" min="1234" '
'step="9999">',
)
def test_fieldset(self):
class TestForm(Form):
template_name = "forms_tests/use_fieldset.html"
field = CharField(widget=self.widget)
form = TestForm()
self.assertIs(self.widget.use_fieldset, False)
self.assertHTMLEqual(
'<div><label for="id_field">Field:</label>'
'<input id="id_field" max="12345" min="1234" '
'name="field" required step="9999" type="number"></div>',
form.render(),
)