2022-01-14 07:08:38 +08:00
|
|
|
from django.forms import CharField, Form, NumberInput
|
2017-06-17 20:12:05 +08:00
|
|
|
from django.test import override_settings
|
|
|
|
|
|
|
|
from .base import WidgetTest
|
|
|
|
|
|
|
|
|
|
|
|
class NumberInputTests(WidgetTest):
|
2022-01-14 07:08:38 +08:00
|
|
|
widget = NumberInput(attrs={"max": 12345, "min": 1234, "step": 9999})
|
|
|
|
|
2021-09-09 13:42:05 +08:00
|
|
|
@override_settings(USE_THOUSAND_SEPARATOR=True)
|
2017-06-17 20:12:05 +08:00
|
|
|
def test_attrs_not_localized(self):
|
|
|
|
self.check_html(
|
2022-01-14 07:08:38 +08:00
|
|
|
self.widget,
|
2017-06-17 20:12:05 +08:00
|
|
|
"name",
|
|
|
|
"value",
|
2018-01-21 15:09:10 +08:00
|
|
|
'<input type="number" name="name" value="value" max="12345" min="1234" '
|
|
|
|
'step="9999">',
|
2017-06-17 20:12:05 +08:00
|
|
|
)
|
2022-01-14 07:08:38 +08:00
|
|
|
|
|
|
|
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(),
|
|
|
|
)
|