diff options
| author | jay20162016 <jayjay.jay20162016@gmail.com> | 2020-03-14 12:32:19 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-03-16 08:44:43 +0100 |
| commit | 924c01ba095f7df9529a65c176a892a5c1624ec5 (patch) | |
| tree | 3315aff6f35226bcbcea1362e9a824925235eb1a /tests/humanize_tests | |
| parent | 3857a08bdb05e30f90f56a7dd0d505ad19f4c403 (diff) | |
Fixed #31363 -- Added support for negative integers to intword template filter.
Diffstat (limited to 'tests/humanize_tests')
| -rw-r--r-- | tests/humanize_tests/tests.py | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/tests/humanize_tests/tests.py b/tests/humanize_tests/tests.py index 7396c417ab..a0d16bbfed 100644 --- a/tests/humanize_tests/tests.py +++ b/tests/humanize_tests/tests.py @@ -99,19 +99,27 @@ class HumanizeTests(SimpleTestCase): self.humanize_tester([100], ['100'], 'intcomma') def test_intword(self): - test_list = ( + # Positive integers. + test_list_positive = ( '100', '1000000', '1200000', '1290000', '1000000000', '2000000000', '6000000000000', '1300000000000000', '3500000000000000000000', - '8100000000000000000000000000000000', None, ('1' + '0' * 100), + '8100000000000000000000000000000000', ('1' + '0' * 100), ('1' + '0' * 104), ) - result_list = ( + result_list_positive = ( '100', '1.0 million', '1.2 million', '1.3 million', '1.0 billion', '2.0 billion', '6.0 trillion', '1.3 quadrillion', '3.5 sextillion', - '8.1 decillion', None, '1.0 googol', ('1' + '0' * 104), + '8.1 decillion', '1.0 googol', ('1' + '0' * 104), ) + # Negative integers. + test_list_negative = ('-' + test for test in test_list_positive) + result_list_negative = ('-' + result for result in result_list_positive) with translation.override('en'): - self.humanize_tester(test_list, result_list, 'intword') + self.humanize_tester( + (*test_list_positive, *test_list_negative, None), + (*result_list_positive, *result_list_negative, None), + 'intword', + ) def test_i18n_intcomma(self): test_list = (100, 1000, 10123, 10311, 1000000, 1234567.25, @@ -123,17 +131,25 @@ class HumanizeTests(SimpleTestCase): self.humanize_tester(test_list, result_list, 'intcomma') def test_i18n_intword(self): - test_list = ( + # Positive integers. + test_list_positive = ( '100', '1000000', '1200000', '1290000', '1000000000', '2000000000', '6000000000000', ) - result_list = ( + result_list_positive = ( '100', '1,0 Million', '1,2 Millionen', '1,3 Millionen', '1,0 Milliarde', '2,0 Milliarden', '6,0 Billionen', ) + # Negative integers. + test_list_negative = ('-' + test for test in test_list_positive) + result_list_negative = ('-' + result for result in result_list_positive) with self.settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True): with translation.override('de'): - self.humanize_tester(test_list, result_list, 'intword') + self.humanize_tester( + (*test_list_positive, *test_list_negative), + (*result_list_positive, *result_list_negative), + 'intword', + ) def test_apnumber(self): test_list = [str(x) for x in range(1, 11)] |
