Skip to content

Commit 0d8cee2

Browse files
committed
Make money formatting test locale independent
1 parent 057e99c commit 0d8cee2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/banker/formatter/test_html_transactions_formatter.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pytest
2+
from moneyed import format_money
23

4+
from banker.common.locale import get_numeric_locale
35
from banker.formatter.html_transactions_formatter import HtmlTransactionsFormatter
46

57

@@ -31,9 +33,8 @@ def test_given_empty_transactions_when_format_transactions_then_return_empty_tab
3133

3234
def test_given_transactions_when_format_transactions_then_return_html_table_with_headers_and_rows(
3335
html_transactions_formatter_sut, transaction1, transaction2):
34-
html_hard_space = "\xa0"
35-
expected_transaction_1_value = f"-37,35{html_hard_space}zł"
36-
expected_transaction_2_value = f"-200,00{html_hard_space}zł"
36+
expected_transaction_1_value = format_money(transaction1.value, locale=get_numeric_locale())
37+
expected_transaction_2_value = format_money(transaction2.value, locale=get_numeric_locale())
3738
expected_result = ('<table border="1" class="dataframe">\n'
3839
' <thead>\n'
3940
' <tr style="text-align: right;">\n'
@@ -65,3 +66,8 @@ def test_given_transactions_when_format_transactions_then_return_html_table_with
6566
actual_result = html_transactions_formatter_sut.format_transactions([transaction1, transaction2])
6667

6768
assert actual_result == expected_result
69+
# exact format is dependent on locale; try to make tests locale-independent
70+
assert "37" in expected_transaction_1_value
71+
assert "-" in expected_transaction_1_value
72+
assert "200" in expected_transaction_2_value
73+
assert "-" in expected_transaction_2_value

0 commit comments

Comments
 (0)