Commit d73f7996 authored by Nicolas Dumazet's avatar Nicolas Dumazet

Use third argument of assertEquals to print custom error messages, not LOG


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33834 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4fdc918e
...@@ -628,14 +628,15 @@ class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase): ...@@ -628,14 +628,15 @@ class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase):
aggregated_amount_list = transformation.getAggregatedAmountList(context) aggregated_amount_list = transformation.getAggregatedAmountList(context)
expected_amount_list = expected['amount'] expected_amount_list = expected['amount']
expected_amount_list_len = len(expected_amount_list)
actual_amount_list_len = len(aggregated_amount_list)
error_msg = 'number of Amount differs between expected (%d) and ' \
'aggregated (%d) for categories %s' % \
(expected_amount_list_len, actual_amount_list_len,
expected['id'])
# Check the number of aggregated components # Check the number of aggregated components
if len(aggregated_amount_list) != len(expected_amount_list): self.assertEquals(actual_amount_list_len, expected_amount_list_len,
error = 'number of Amount differs between expected (%d) and ' \ error_msg)
'aggregated (%d) for categories %s' % \
(len(expected_amount_list),
len(aggregated_amount_list), expected['id'])
LOG('TEST ERROR :', 0, error)
self.fail(error)
# Check quantity for each component # Check quantity for each component
for i in range(len(aggregated_amount_list)): for i in range(len(aggregated_amount_list)):
...@@ -650,14 +651,12 @@ class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase): ...@@ -650,14 +651,12 @@ class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase):
if e_price is not None and a_price is not None: if e_price is not None and a_price is not None:
if round(a_price,10) != round(e_price,10): if round(a_price,10) != round(e_price,10):
error = 1 error = 1
if error == 1: error_msg = 'Total price differs between expected (%s) and aggregated' \
error = 'Total price differs between expected (%s) and aggregated' \ ' (%s) Amounts (resource : %s, id_categories : %s, ' \
' (%s) Amounts (resource : %s, id_categories : %s, ' \ 'amount.categories : %s)' % \
'amount.categories : %s)' % \ (e_price, a_price, a_amount.getResource(),
(repr(e_price), repr(a_price), repr(a_amount.getResource()),
expected['id'], a_amount.getCategoryList()) expected['id'], a_amount.getCategoryList())
LOG('TEST ERROR :', 0, error) self.failIf(error, error_msg)
self.fail(error)
# Check duration for each component # Check duration for each component
a_duration = a_amount.getDuration() a_duration = a_amount.getDuration()
...@@ -670,24 +669,21 @@ class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase): ...@@ -670,24 +669,21 @@ class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase):
if e_duration is not None and a_duration is not None: if e_duration is not None and a_duration is not None:
if round(a_duration,10) != round(e_duration,10): if round(a_duration,10) != round(e_duration,10):
error = 1 error = 1
if error == 1: error_msg = 'Duration differs between expected (%s) and aggregated (%s)' \
error = 'Duration differs between expected (%s) and aggregated (%s)' \ ' Amounts (resource : %s, id_categories : %s, ' \
' Amounts (resource : %s, id_categories : %s, ' \ 'amount.categories : %s)' % \
'amount.categories : %s)' % \ (e_duration, a_duration,
(repr(e_duration), repr(a_duration), a_amount.getResource(), expected['id'],
repr(a_amount.getResource()), expected['id'],
a_amount.getCategoryList()) a_amount.getCategoryList())
LOG('TEST ERROR :', 0, error) self.failIf(error, error_msg)
self.fail(error)
# Check global quantity # Check global quantity
total_price = aggregated_amount_list.getTotalPrice() total_price = aggregated_amount_list.getTotalPrice()
if round(total_price, 10) != round(expected['total'], 10): error_msg = 'Total price for AggregatedAmountList differs between ' \
error = 'Total price for AggregatedAmountList differs between ' \ 'expected (%s) and aggregated (%s) (%s)' % \
'expected (%s) and aggregated (%s) (%s)' % \ (total_price, expected['total'], expected['id'])
(repr(total_price), repr(expected['total']), expected['id']) self.assertEquals(round(total_price, 10), round(expected['total'], 10),
LOG('TEST ERROR :', 0, error) error_msg)
self.fail(error)
# Check global duration # Check global duration
total_duration = aggregated_amount_list.getTotalDuration() total_duration = aggregated_amount_list.getTotalDuration()
...@@ -701,14 +697,13 @@ class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase): ...@@ -701,14 +697,13 @@ class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase):
if round(total_duration, 10) != round(expected_duration, 10): if round(total_duration, 10) != round(expected_duration, 10):
error = 1 error = 1
if error == 1: if error == 1:
error='Total duration differs between expected (%s) and ' \ error_msg = 'Total duration differs between expected (%s) and ' \
'aggregated (%s) (%s)' % \ 'aggregated (%s) (%s)' % \
(repr(expected_duration), repr(total_duration), (expected_duration, total_duration, expected['id'])
expected['id']) LOG('TEST ERROR :', 0, error_msg)
LOG('TEST ERROR :', 0, error) # XXX Is it alright to exit this test with an error without raising
# XXX Is it alright to exit this test with an error without raising # anything?
# anything? # self.failIf(error, error_msg)
# self.fail(error)
def test_01_getAggregatedAmountList(self, quiet=0, run=run_all_test): def test_01_getAggregatedAmountList(self, quiet=0, run=run_all_test):
......
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