Added the six module to test int/long support

This commit is contained in:
Konstantin Gukov
2016-03-06 16:10:02 +05:00
committed by Konstantin Gukov
parent fed58f3920
commit 66b233eaea
4 changed files with 12 additions and 6 deletions

View File

@@ -8,6 +8,8 @@ import uuid
import warnings
from operator import itemgetter
import six
try:
import dateutil
except ImportError:
@@ -260,14 +262,14 @@ class FloatField(BaseField):
return value
def validate(self, value):
if isinstance(value, (int, long)):
if isinstance(value, six.integer_types):
try:
value = float(value)
except OverflowError:
self.error('The value is too large to be converted to float')
if not isinstance(value, float):
self.error('FloatField only accepts float, int and long values')
self.error('FloatField only accepts float and integer values')
if self.min_value is not None and value < self.min_value:
self.error('Float value is too small')