From 9b5922b6df5f54ac1b8507601a7c5cd4d5a27bf2 Mon Sep 17 00:00:00 2001 From: Mauro Scomparin Date: Tue, 10 Jul 2018 22:02:43 +0200 Subject: [PATCH] consolidated message printing with value_message function --- money/money.py | 10 +++++----- money/tests/test_money.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/money/money.py b/money/money.py index db67368..9183678 100755 --- a/money/money.py +++ b/money/money.py @@ -186,8 +186,8 @@ def last_movement_number_message(n): return 'latest {} movements:'.format(n) -def actual_value_message(value): - return 'actual value: {}'.format(str(value)) +def value_message(str, value): + return str.format(value) def write_latest_movements(data_file, conf): @@ -203,9 +203,9 @@ def write_latest_movements(data_file, conf): total_incomes = total_incomes + movement_value else: total_expenses = total_expenses + movement_value - print(actual_value_message(actual_value)) - print('total incomes:', str(total_incomes)) - print('total expenses:', str(total_expenses)) + print(value_message('actual value: {}', actual_value)) + print(value_message('total incomes: {}', total_incomes)) + print(value_message('total expenses: {}', total_expenses)) print(last_movement_number_message(conf[LAST_MOVEMENT_NUMBER])) for i in range(conf[LAST_MOVEMENT_NUMBER]): if i < len(ordered_movements): diff --git a/money/tests/test_money.py b/money/tests/test_money.py index a402cc8..fa1578c 100644 --- a/money/tests/test_money.py +++ b/money/tests/test_money.py @@ -15,9 +15,9 @@ class MoneyTest(unittest.TestCase): self.assertEqual(money.last_movement_number_message( 10), "latest 10 movements:") - def test_actual_value_message(self): - self.assertEqual(money.actual_value_message( - Decimal(10.00)), "actual value: 10") + def test_value_message(self): + self.assertEqual(money.value_message('blah: {}', + Decimal(10.00)), "blah: 10") def test_config_file_name(self): self.assertEqual(money.CONFIG_FILE_NAME, 'money.conf') -- 2.25.1