mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +00:00
Fixed #34473 -- Fixed step validation for form fields with non-zero minimum value.
This commit is contained in:
parent
549d6ffeb6
commit
1fe0b167af
9 changed files with 129 additions and 8 deletions
|
|
@ -126,6 +126,22 @@ class IntegerFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
|
|||
self.assertEqual(12, f.clean("12"))
|
||||
self.assertEqual(f.step_size, 3)
|
||||
|
||||
def test_integerfield_step_size_min_value(self):
|
||||
f = IntegerField(step_size=3, min_value=-1)
|
||||
self.assertWidgetRendersTo(
|
||||
f,
|
||||
'<input name="f" min="-1" step="3" type="number" id="id_f" required>',
|
||||
)
|
||||
msg = (
|
||||
"Ensure this value is a multiple of step size 3, starting from -1, e.g. "
|
||||
"-1, 2, 5, and so on."
|
||||
)
|
||||
with self.assertRaisesMessage(ValidationError, msg):
|
||||
f.clean("9")
|
||||
self.assertEqual(f.clean("2"), 2)
|
||||
self.assertEqual(f.clean("-1"), -1)
|
||||
self.assertEqual(f.step_size, 3)
|
||||
|
||||
def test_integerfield_localized(self):
|
||||
"""
|
||||
A localized IntegerField's widget renders to a text input without any
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue