Skip to content

Commit

Permalink
[FIX] point_of_sale: incorrect assertAlmostEqual
Browse files Browse the repository at this point in the history
The third parameter to assertAlmostEqual is a precision (places), not the
assertion message. This goes unnoticed when using two objects which are
strictly equal because assertAlmostEqual shortcuts if the two inputs are equal,
before falling back on approximation.

Since the parameters here are two integers, they're always going to be either 
identical or completely different, therefore the issue is only visible if the assertion 
fails, hiding the assertion error.

* pass the message by keyword
* replace assertAlmostEqual by assertEqual as the inputs are integers and integers
  can't really be "almost" equal

closes #40015

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
  • Loading branch information
xmo-odoo committed Nov 8, 2019
1 parent 19bf61c commit f22e717
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addons/point_of_sale/tests/test_pos_basic_config.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def test_return_order(self):
session_move = self.pos_session.move_id session_move = self.pos_session.move_id


sale_lines = session_move.line_ids.filtered(lambda line: line.account_id == self.sale_account) sale_lines = session_move.line_ids.filtered(lambda line: line.account_id == self.sale_account)
self.assertAlmostEqual(len(sale_lines), 2, 'There should be lines for both sales and refund.') self.assertEqual(len(sale_lines), 2, msg='There should be lines for both sales and refund.')
self.assertAlmostEqual(sum(sale_lines.mapped('balance')), -110.0) self.assertAlmostEqual(sum(sale_lines.mapped('balance')), -110.0)


receivable_line_bank = session_move.line_ids.filtered(lambda line: self.bank_pm.name in line.name) receivable_line_bank = session_move.line_ids.filtered(lambda line: self.bank_pm.name in line.name)
Expand Down Expand Up @@ -434,4 +434,4 @@ def test_split_cash_payments(self):
self.assertAlmostEqual(sum(cash_receivable_lines.mapped('balance')), 290, msg='Total cash receivable balance should be equal to the total cash payments.') self.assertAlmostEqual(sum(cash_receivable_lines.mapped('balance')), 290, msg='Total cash receivable balance should be equal to the total cash payments.')


for line in cash_receivable_lines: for line in cash_receivable_lines:
self.assertTrue(line.full_reconcile_id, msg='Each cash receivable line should be fully-reconciled.') self.assertTrue(line.full_reconcile_id, msg='Each cash receivable line should be fully-reconciled.')

0 comments on commit f22e717

Please sign in to comment.