Commit ce667c12 authored by Julien Muchembled's avatar Julien Muchembled

TestFloatField: fix test_render_big_numbers on Python 2.7

parent 64c1fd42
...@@ -166,9 +166,9 @@ class TestFloatField(ERP5TypeTestCase): ...@@ -166,9 +166,9 @@ class TestFloatField(ERP5TypeTestCase):
def test_render_big_numbers(self): def test_render_big_numbers(self):
self.field.values['precision'] = 2 self.field.values['precision'] = 2
self.field.values['editable'] = 0 self.field.values['editable'] = 0
self.assertEquals('10000000000000000000.00', self.assertEquals('10000000000000.00',
self.field.render(10000000000000000000)) self.field.render(10000000000000))
self.assertEquals('1e+100', self.field.render(1e+100)) self.assertEquals('1e+20', self.field.render(1e+20))
def test_validate_thousand_separator_point(self): def test_validate_thousand_separator_point(self):
self.field.values['input_style'] = '-1 234.5' self.field.values['input_style'] = '-1 234.5'
......
...@@ -1812,7 +1812,9 @@ class FloatWidget(TextWidget): ...@@ -1812,7 +1812,9 @@ class FloatWidget(TextWidget):
float_value = float(value) float_value = float(value)
if percent: if percent:
float_value *= 100 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 # if we have a precision, then use it now
value = ('%%0.%sf' % precision) % float_value value = ('%%0.%sf' % precision) % float_value
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment