From 58aebf10698e0f34102819a21e5b0e511d4190b4 Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Sun, 25 Sep 2016 16:52:23 +0200 Subject: [PATCH] Fix unit test rounding : Test was Ok but failed due to some floating point errors. --- budget/tests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/budget/tests.py b/budget/tests.py index 0e40825..2ee3d81 100644 --- a/budget/tests.py +++ b/budget/tests.py @@ -498,7 +498,10 @@ class BudgetTestCase(TestCase): result[models.Project.query.get("raclette").members[0].id] = 8.12 result[models.Project.query.get("raclette").members[1].id] = 0.0 result[models.Project.query.get("raclette").members[2].id] = -8.12 - self.assertDictEqual(balance, result) + # Since we're using floating point to store currency, we can have some rounding issues that prevent test from working. + # However, we should obtain the same values as the theorical ones if we round to 2 decimals, like in the UI. + for key, value in balance.iteritems(): + self.assertEqual(round(value, 2), result[key]) def test_edit_project(self): # A project should be editable