mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-16 07:02:10 +03:00
Use Decimal for min/max values of DecimalField in tests
This commit is contained in:
parent
f593f5752c
commit
4e83673a4a
|
@ -2,6 +2,7 @@
|
|||
This test "app" exists to ensure that parts of Django REST Framework can be
|
||||
imported/invoked before Django itself has been fully initialized.
|
||||
"""
|
||||
from decimal import Decimal
|
||||
|
||||
from rest_framework import compat, serializers # noqa
|
||||
|
||||
|
@ -11,6 +12,8 @@ class ExampleSerializer(serializers.Serializer):
|
|||
charfield = serializers.CharField(min_length=1, max_length=2)
|
||||
integerfield = serializers.IntegerField(min_value=1, max_value=2)
|
||||
floatfield = serializers.FloatField(min_value=1, max_value=2)
|
||||
decimalfield = serializers.DecimalField(max_digits=10, decimal_places=1, min_value=1, max_value=2)
|
||||
decimalfield = serializers.DecimalField(
|
||||
max_digits=10, decimal_places=1, min_value=Decimal(1), max_value=Decimal(2)
|
||||
)
|
||||
durationfield = serializers.DurationField(min_value=1, max_value=2)
|
||||
listfield = serializers.ListField(min_length=1, max_length=2)
|
||||
|
|
|
@ -1291,12 +1291,14 @@ class TestAllowEmptyStrDecimalFieldWithValidators(FieldValues):
|
|||
outputs = {
|
||||
None: '',
|
||||
}
|
||||
field = serializers.DecimalField(max_digits=3, decimal_places=1, allow_null=True, min_value=0, max_value=10)
|
||||
field = serializers.DecimalField(
|
||||
max_digits=3, decimal_places=1, allow_null=True, min_value=Decimal(0), max_value=Decimal(10)
|
||||
)
|
||||
|
||||
|
||||
class TestNoMaxDigitsDecimalField(FieldValues):
|
||||
field = serializers.DecimalField(
|
||||
max_value=100, min_value=0,
|
||||
max_value=Decimal(100), min_value=Decimal(0),
|
||||
decimal_places=2, max_digits=None
|
||||
)
|
||||
valid_inputs = {
|
||||
|
|
Loading…
Reference in New Issue
Block a user