summaryrefslogtreecommitdiff
path: root/odoo/addons/base/tests/test_float.py
diff options
context:
space:
mode:
authorJorge Pinna Puissant <jpp@odoo.com>2019-01-30 09:12:18 +0000
committerJorge Pinna Puissant <jpp@odoo.com>2019-02-13 07:05:13 +0000
commite270e9e0cc6574d2c6bdd29983d3b66d12d2ced7 (patch)
tree82e1303f90932a05086a600c1b4d38cbb2fea23c /odoo/addons/base/tests/test_float.py
parent73fa0748da28ac475520aa390459ace55fe076c1 (diff)
[IMP] tools: float_utils, precision rounding must be positive
Adding a new rule to verify that precision_rounding is positive. Before this commit: when a precision_round was 0 or smaller than 0 the float_utils functions gave as results: * float_is_zero(0.0, precision_rounding=0.0) -> False * float_round(1.25, precision_rounding=0.0) -> 0.0 * float_compare(1.0, 1.0, precision_rounding=0.0) -> 1 These results where at least not correct at worst not logic. Now, the function raises an error when the precision_rounding is not positive
Diffstat (limited to 'odoo/addons/base/tests/test_float.py')
-rw-r--r--odoo/addons/base/tests/test_float.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/odoo/addons/base/tests/test_float.py b/odoo/addons/base/tests/test_float.py
index 4447b9de1c0..4dbf1f5f139 100644
--- a/odoo/addons/base/tests/test_float.py
+++ b/odoo/addons/base/tests/test_float.py
@@ -202,11 +202,29 @@ class TestFloatPrecision(TransactionCase):
float_is_zero(0.01, precision_digits=3, precision_rounding=0.01)
with self.assertRaises(AssertionError):
+ float_is_zero(0.0, precision_rounding=0.0)
+
+ with self.assertRaises(AssertionError):
+ float_is_zero(0.0, precision_rounding=-0.1)
+
+ with self.assertRaises(AssertionError):
float_compare(0.01, 0.02, precision_digits=3, precision_rounding=0.01)
with self.assertRaises(AssertionError):
+ float_compare(1.0, 1.0, precision_rounding=0.0)
+
+ with self.assertRaises(AssertionError):
+ float_compare(1.0, 1.0, precision_rounding=-0.1)
+
+ with self.assertRaises(AssertionError):
float_round(0.01, precision_digits=3, precision_rounding=0.01)
+ with self.assertRaises(AssertionError):
+ float_round(1.25, precision_rounding=0.0)
+
+ with self.assertRaises(AssertionError):
+ float_round(1.25, precision_rounding=-0.1)
+
def test_amount_to_text_10(self):
""" verify that amount_to_text works as expected """
currency = self.env.ref('base.EUR')