summaryrefslogtreecommitdiff
path: root/tests/template_tests/filter_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-09-08 08:37:27 +0200
committerGitHub <noreply@github.com>2021-09-08 08:37:27 +0200
commit4a43335d300da942602fbf216cd0a53b60827ab4 (patch)
tree0fa559e6c92066934e0c79cada2293b986e56e29 /tests/template_tests/filter_tests
parent301a85a12f3c2c9427c7ff581fd4683bab1f29f6 (diff)
downloaddjango-4a43335d300da942602fbf216cd0a53b60827ab4.tar.gz
Fixed #30086, Refs #32873 -- Made floatformat template filter independent of USE_L10N.
Diffstat (limited to 'tests/template_tests/filter_tests')
-rw-r--r--tests/template_tests/filter_tests/test_floatformat.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/template_tests/filter_tests/test_floatformat.py b/tests/template_tests/filter_tests/test_floatformat.py
index 64d65f7dc4..1035fb96da 100644
--- a/tests/template_tests/filter_tests/test_floatformat.py
+++ b/tests/template_tests/filter_tests/test_floatformat.py
@@ -2,7 +2,6 @@ from decimal import Decimal, localcontext
from django.template.defaultfilters import floatformat
from django.test import SimpleTestCase
-from django.test.utils import override_settings
from django.utils import translation
from django.utils.safestring import mark_safe
@@ -60,7 +59,6 @@ class FunctionTests(SimpleTestCase):
self.assertEqual(floatformat(1.5e-15, -20), '0.00000000000000150000')
self.assertEqual(floatformat(1.00000000000000015, 16), '1.0000000000000002')
- @override_settings(USE_L10N=True)
def test_force_grouping(self):
with translation.override('en'):
self.assertEqual(floatformat(10000, 'g'), '10,000')
@@ -73,6 +71,20 @@ class FunctionTests(SimpleTestCase):
# Invalid suffix.
self.assertEqual(floatformat(10000, 'g2'), '10000')
+ def test_unlocalize(self):
+ with translation.override('de', deactivate=True):
+ self.assertEqual(floatformat(66666.666, '2'), '66666,67')
+ self.assertEqual(floatformat(66666.666, '2u'), '66666.67')
+ with self.settings(
+ USE_THOUSAND_SEPARATOR=True,
+ NUMBER_GROUPING=3,
+ THOUSAND_SEPARATOR='!',
+ ):
+ self.assertEqual(floatformat(66666.666, '2gu'), '66!666.67')
+ self.assertEqual(floatformat(66666.666, '2ug'), '66!666.67')
+ # Invalid suffix.
+ self.assertEqual(floatformat(66666.666, 'u2'), '66666.666')
+
def test_zero_values(self):
self.assertEqual(floatformat(0, 6), '0.000000')
self.assertEqual(floatformat(0, 7), '0.0000000')