Skip to content

Commit 4e83673

Browse files
committed
Use Decimal for min/max values of DecimalField in tests
1 parent f593f57 commit 4e83673

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

tests/importable/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
This test "app" exists to ensure that parts of Django REST Framework can be
33
imported/invoked before Django itself has been fully initialized.
44
"""
5+
from decimal import Decimal
56

67
from rest_framework import compat, serializers # noqa
78

@@ -11,6 +12,8 @@ class ExampleSerializer(serializers.Serializer):
1112
charfield = serializers.CharField(min_length=1, max_length=2)
1213
integerfield = serializers.IntegerField(min_value=1, max_value=2)
1314
floatfield = serializers.FloatField(min_value=1, max_value=2)
14-
decimalfield = serializers.DecimalField(max_digits=10, decimal_places=1, min_value=1, max_value=2)
15+
decimalfield = serializers.DecimalField(
16+
max_digits=10, decimal_places=1, min_value=Decimal(1), max_value=Decimal(2)
17+
)
1518
durationfield = serializers.DurationField(min_value=1, max_value=2)
1619
listfield = serializers.ListField(min_length=1, max_length=2)

tests/test_fields.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,12 +1291,14 @@ class TestAllowEmptyStrDecimalFieldWithValidators(FieldValues):
12911291
outputs = {
12921292
None: '',
12931293
}
1294-
field = serializers.DecimalField(max_digits=3, decimal_places=1, allow_null=True, min_value=0, max_value=10)
1294+
field = serializers.DecimalField(
1295+
max_digits=3, decimal_places=1, allow_null=True, min_value=Decimal(0), max_value=Decimal(10)
1296+
)
12951297

12961298

12971299
class TestNoMaxDigitsDecimalField(FieldValues):
12981300
field = serializers.DecimalField(
1299-
max_value=100, min_value=0,
1301+
max_value=Decimal(100), min_value=Decimal(0),
13001302
decimal_places=2, max_digits=None
13011303
)
13021304
valid_inputs = {

0 commit comments

Comments
 (0)