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

Fixed #34473 -- Fixed step validation for form fields with non-zero minimum value.

This commit is contained in:
Jacob Rief
2023-04-08 22:10:17 +02:00
committed by Mariusz Felisiak
parent 549d6ffeb6
commit 1fe0b167af
9 changed files with 129 additions and 8 deletions

View File

@@ -451,11 +451,39 @@ TEST_DATA = [
(StepValueValidator(3), 1, ValidationError),
(StepValueValidator(3), 8, ValidationError),
(StepValueValidator(3), 9, None),
(StepValueValidator(2), 4, None),
(StepValueValidator(2, offset=1), 3, None),
(StepValueValidator(2, offset=1), 4, ValidationError),
(StepValueValidator(0.001), 0.55, None),
(StepValueValidator(0.001), 0.5555, ValidationError),
(StepValueValidator(0.001, offset=0.0005), 0.5555, None),
(StepValueValidator(0.001, offset=0.0005), 0.555, ValidationError),
(StepValueValidator(Decimal(0.02)), 0.88, None),
(StepValueValidator(Decimal(0.02)), Decimal(0.88), None),
(StepValueValidator(Decimal(0.02)), Decimal(0.77), ValidationError),
(StepValueValidator(Decimal(0.02), offset=Decimal(0.01)), Decimal(0.77), None),
(StepValueValidator(Decimal(2.0), offset=Decimal(0.1)), Decimal(0.1), None),
(
StepValueValidator(Decimal(0.02), offset=Decimal(0.01)),
Decimal(0.88),
ValidationError,
),
(StepValueValidator(Decimal("1.2"), offset=Decimal("2.2")), Decimal("3.4"), None),
(
StepValueValidator(Decimal("1.2"), offset=Decimal("2.2")),
Decimal("1.2"),
ValidationError,
),
(
StepValueValidator(Decimal("-1.2"), offset=Decimal("2.2")),
Decimal("1.1"),
ValidationError,
),
(
StepValueValidator(Decimal("-1.2"), offset=Decimal("2.2")),
Decimal("1.0"),
None,
),
(URLValidator(EXTENDED_SCHEMES), "file://localhost/path", None),
(URLValidator(EXTENDED_SCHEMES), "git://example.com/", None),
(