Commit ce667c12 by Julien Muchembled

TestFloatField: fix test_render_big_numbers on Python 2.7

1 parent 64c1fd42
......@@ -166,9 +166,9 @@ class TestFloatField(ERP5TypeTestCase):
def test_render_big_numbers(self):
self.field.values['precision'] = 2
self.field.values['editable'] = 0
self.assertEquals('10000000000000000000.00',
self.field.render(10000000000000000000))
self.assertEquals('1e+100', self.field.render(1e+100))
self.assertEquals('10000000000000.00',
self.field.render(10000000000000))
self.assertEquals('1e+20', self.field.render(1e+20))
def test_validate_thousand_separator_point(self):
self.field.values['input_style'] = '-1 234.5'
......
......@@ -1812,7 +1812,9 @@ class FloatWidget(TextWidget):
float_value = float(value)
if percent:
float_value *= 100
if precision not in (None, ''):
if precision not in (None, '') and (
# ignore precision for too big absolute numbers
abs(float_value) * 10**precision < 2**53):
# if we have a precision, then use it now
value = ('%%0.%sf' % precision) % float_value
else:
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!