summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2020-06-04 09:13:40 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-06-04 11:00:33 +0200
commit810e656aca21a2389c1666e1cb132f6dd02a1e4b (patch)
tree5411a531ab4f523263c7541f195b01cf8345915e
parent43254876c250a7d470313112cc7750a43ffbd92e (diff)
[3.1.x] Refs #30134 -- Added test for {% localize off %} tag with format settings.
Backport of 51250d2f123b694ab7e09c119cb72d4878266688 from master
-rw-r--r--tests/i18n/tests.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index feca7b856f..9b2d1258bc 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -1206,6 +1206,24 @@ class FormattingTests(SimpleTestCase):
self.assertEqual(template2.render(context), output2)
self.assertEqual(template3.render(context), output3)
+ def test_localized_off_numbers(self):
+ """A string representation is returned for unlocalized numbers."""
+ template = Template(
+ '{% load l10n %}{% localize off %}'
+ '{{ int }}/{{ float }}/{{ decimal }}{% endlocalize %}'
+ )
+ context = Context(
+ {'int': 1455, 'float': 3.14, 'decimal': decimal.Decimal('24.1567')}
+ )
+ for use_l10n in [True, False]:
+ with self.subTest(use_l10n=use_l10n), self.settings(
+ USE_L10N=use_l10n,
+ USE_THOUSAND_SEPARATOR=True,
+ THOUSAND_SEPARATOR='°',
+ NUMBER_GROUPING=2,
+ ):
+ self.assertEqual(template.render(context), '1455/3.14/24.1567')
+
def test_localized_as_text_as_hidden_input(self):
"""
Tests if form input with 'as_hidden' or 'as_text' is correctly localized. Ticket #18777