Commit 580a4224 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Formulator: FloatField with precision equals to 0 didn't apply input_style (ce667c12).

parent af640e28
...@@ -106,6 +106,11 @@ class TestFloatField(ERP5TypeTestCase): ...@@ -106,6 +106,11 @@ class TestFloatField(ERP5TypeTestCase):
self.assertEquals('100,000.0', self.widget.format_value(self.field, 100000)) self.assertEquals('100,000.0', self.widget.format_value(self.field, 100000))
self.assertEquals('-100,000.0', self.widget.format_value(self.field, -100000)) self.assertEquals('-100,000.0', self.widget.format_value(self.field, -100000))
def test_format_with_separator_and_precision0(self):
self.field.values['input_style'] = '-1,234.5'
self.field.values['precision'] = 0
self.assertEquals('-1,000', self.widget.format_value(self.field, -1000.25))
def test_format_percent_style(self): def test_format_percent_style(self):
self.field.values['input_style'] = '-12.3%' self.field.values['input_style'] = '-12.3%'
self.assertEquals('10.0%', self.widget.format_value(self.field, 0.1)) self.assertEquals('10.0%', self.widget.format_value(self.field, 0.1))
......
...@@ -1823,6 +1823,7 @@ class FloatWidget(TextWidget): ...@@ -1823,6 +1823,7 @@ class FloatWidget(TextWidget):
# just return it as is # just return it as is
if 'e' in value: if 'e' in value:
return value return value
if precision != 0:
value, fpart = value.split('.') value, fpart = value.split('.')
except ValueError: except ValueError:
return value return value
......
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