diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index 9d50469615..7cddd7c6cf 100644
a
|
b
|
class FormattingTests(SimpleTestCase):
|
993 | 993 | |
994 | 994 | def test_localize_templatetag_and_filter(self): |
995 | 995 | """ |
996 | | Tests the {% localize %} templatetag |
| 996 | Test the {% localize %} templatetag and the localize/unlocalize filters. |
997 | 997 | """ |
998 | | context = Context({'value': 3.14}) |
| 998 | context = Context({'float': 3.14, 'date': datetime.date(2016, 12, 31)}) |
999 | 999 | template1 = Template( |
1000 | | '{% load l10n %}{% localize %}{{ value }}{% endlocalize %};' |
1001 | | '{% localize on %}{{ value }}{% endlocalize %}' |
| 1000 | '{% load l10n %}{% localize %}{{ float }}/{{ date }}{% endlocalize %}; ' |
| 1001 | '{% localize on %}{{ float }}/{{ date }}{% endlocalize %}' |
1002 | 1002 | ) |
1003 | | template2 = Template("{% load l10n %}{{ value }};{% localize off %}{{ value }};{% endlocalize %}{{ value }}") |
1004 | | template3 = Template('{% load l10n %}{{ value }};{{ value|unlocalize }}') |
1005 | | template4 = Template('{% load l10n %}{{ value }};{{ value|localize }}') |
1006 | | output1 = '3,14;3,14' |
1007 | | output2 = '3,14;3.14;3,14' |
1008 | | output3 = '3,14;3.14' |
1009 | | output4 = '3.14;3,14' |
| 1003 | template2 = Template( |
| 1004 | '{% load l10n %}{{ float }}/{{ date }}; ' |
| 1005 | '{% localize off %}{{ float }}/{{ date }};{% endlocalize %} ' |
| 1006 | '{{ float }}/{{ date }}' |
| 1007 | ) |
| 1008 | template3 = Template( |
| 1009 | '{% load l10n %}{{ float }}/{{ date }}; {{ float|unlocalize }}/{{ date|unlocalize }}' |
| 1010 | ) |
| 1011 | template4 = Template( |
| 1012 | '{% load l10n %}{{ float }}/{{ date }}; {{ float|localize }}/{{ date|localize }}' |
| 1013 | ) |
| 1014 | expected_localized = '3,14/31. Dezember 2016' |
| 1015 | expected_unlocalized = '3.14/Dez. 31, 2016' |
| 1016 | output1 = '; '.join([expected_localized, expected_localized]) |
| 1017 | output2 = '; '.join([expected_localized, expected_unlocalized, expected_localized]) |
| 1018 | output3 = '; '.join([expected_localized, expected_unlocalized]) |
| 1019 | output4 = '; '.join([expected_unlocalized, expected_localized]) |
1010 | 1020 | with translation.override('de', deactivate=True): |
1011 | 1021 | with self.settings(USE_L10N=False): |
1012 | 1022 | self.assertEqual(template1.render(context), output1) |