Added the six module to test int/long support
This commit is contained in:
parent
fed58f3920
commit
66b233eaea
@ -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')
|
||||
|
@ -1,2 +1,3 @@
|
||||
pymongo>=2.7.1
|
||||
nose
|
||||
pymongo>=2.7.1
|
||||
six==1.10.0
|
||||
|
2
setup.py
2
setup.py
@ -78,7 +78,7 @@ setup(name='mongoengine',
|
||||
long_description=LONG_DESCRIPTION,
|
||||
platforms=['any'],
|
||||
classifiers=CLASSIFIERS,
|
||||
install_requires=['pymongo>=2.7.1'],
|
||||
install_requires=['pymongo>=2.7.1', 'six'],
|
||||
test_suite='nose.collector',
|
||||
**extra_opts
|
||||
)
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
|
||||
import six
|
||||
from nose.plugins.skip import SkipTest
|
||||
|
||||
sys.path[0:0] = [""]
|
||||
@ -420,8 +422,9 @@ class FieldTest(unittest.TestCase):
|
||||
|
||||
big_person = BigPerson()
|
||||
|
||||
big_person.height = 1L
|
||||
big_person.validate()
|
||||
for value, value_type in enumerate(six.integer_types):
|
||||
big_person.height = value_type(value)
|
||||
big_person.validate()
|
||||
|
||||
big_person.height = 2 ** 500
|
||||
big_person.validate()
|
||||
|
Loading…
x
Reference in New Issue
Block a user