mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #29578 -- Made numberformat.format() honor forced l10n usage.
Thanks Sassan Haradji for the report.
This commit is contained in:
parent
6b6bdfe25c
commit
0adfba968e
5 changed files with 26 additions and 18 deletions
|
@ -1,11 +1,11 @@
|
|||
from decimal import Decimal
|
||||
from sys import float_info
|
||||
from unittest import TestCase
|
||||
|
||||
from django.test import SimpleTestCase
|
||||
from django.utils.numberformat import format as nformat
|
||||
|
||||
|
||||
class TestNumberFormat(TestCase):
|
||||
class TestNumberFormat(SimpleTestCase):
|
||||
|
||||
def test_format_number(self):
|
||||
self.assertEqual(nformat(1234, '.'), '1234')
|
||||
|
@ -14,6 +14,11 @@ class TestNumberFormat(TestCase):
|
|||
self.assertEqual(nformat(1234, '.', grouping=2, thousand_sep=','), '1234')
|
||||
self.assertEqual(nformat(1234, '.', grouping=2, thousand_sep=',', force_grouping=True), '12,34')
|
||||
self.assertEqual(nformat(-1234.33, '.', decimal_pos=1), '-1234.3')
|
||||
# The use_l10n parameter can force thousand grouping behavior.
|
||||
with self.settings(USE_THOUSAND_SEPARATOR=True, USE_L10N=True):
|
||||
self.assertEqual(nformat(1234, '.', grouping=3, thousand_sep=',', use_l10n=False), '1234')
|
||||
with self.settings(USE_THOUSAND_SEPARATOR=True, USE_L10N=False):
|
||||
self.assertEqual(nformat(1234, '.', grouping=3, thousand_sep=',', use_l10n=True), '1,234')
|
||||
|
||||
def test_format_string(self):
|
||||
self.assertEqual(nformat('1234', '.'), '1234')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue