From 081924b014df1123c6ea02af5a632df7ed5297fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 3 Oct 2013 21:19:25 +0200 Subject: [PATCH] Add unittest for infinite loop when setting internal_quantity issue3332 review1109002 --- tests/test_stock.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/test_stock.py b/tests/test_stock.py index f0f6c7cc9d..f83c0752a1 100644 --- a/tests/test_stock.py +++ b/tests/test_stock.py @@ -84,11 +84,12 @@ class StockTestCase(unittest.TestCase): }) tests = [ - (kg, 10, 10), - (g, 100, 0.1), - (g, 1, 0), # rounded + (kg, 10, 10, 0), + (g, 100, 0.1, 1), + (g, 1, 0, 0), # rounded + (kg, 35.23, 35.23, 2), # check infinite loop ] - for uom, quantity, internal_quantity in tests: + for uom, quantity, internal_quantity, ndigits in tests: move, = self.move.create([{ 'product': product.id, 'uom': uom.id, @@ -99,14 +100,16 @@ class StockTestCase(unittest.TestCase): 'unit_price': Decimal('1'), 'currency': currency.id, }]) - self.assertEqual(move.internal_quantity, internal_quantity) + self.assertEqual(round(move.internal_quantity, ndigits), + internal_quantity) - for uom, quantity, internal_quantity in tests: + for uom, quantity, internal_quantity, ndigits in tests: self.move.write([move], { 'uom': uom.id, 'quantity': quantity, }) - self.assertEqual(move.internal_quantity, internal_quantity) + self.assertEqual(round(move.internal_quantity, ndigits), + internal_quantity) def test0020products_by_location(self): '''