summaryrefslogtreecommitdiff
path: root/tests/utils_tests/test_numberformat.py
diff options
context:
space:
mode:
authorEric Rouleau <xblitz@gmail.com>2014-11-30 03:29:52 -0500
committerTim Graham <timograham@gmail.com>2014-12-03 07:49:06 -0500
commit9d1a69579b996eaa208f141b409141be63f597ec (patch)
treeff1102914e734b8e3ab4f47d2fe3e77769593519 /tests/utils_tests/test_numberformat.py
parentadacbd64a062662f54d6e91dc4e460eff96b5dd5 (diff)
Fixed #23935 -- Converted decimals to fixed point in utils.numberformat.format
Diffstat (limited to 'tests/utils_tests/test_numberformat.py')
-rw-r--r--tests/utils_tests/test_numberformat.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/utils_tests/test_numberformat.py b/tests/utils_tests/test_numberformat.py
index f9d9031e48..80f222d955 100644
--- a/tests/utils_tests/test_numberformat.py
+++ b/tests/utils_tests/test_numberformat.py
@@ -1,6 +1,8 @@
+from decimal import Decimal
+from sys import float_info
from unittest import TestCase
+
from django.utils.numberformat import format as nformat
-from sys import float_info
class TestNumberFormat(TestCase):
@@ -45,3 +47,12 @@ class TestNumberFormat(TestCase):
self.assertEqual(nformat(0 - int_max, '.'), most_max.format('-', '8'))
self.assertEqual(nformat(-1 - int_max, '.'), most_max.format('-', '9'))
self.assertEqual(nformat(-2 * int_max, '.'), most_max2.format('-'))
+
+ def test_decimal_numbers(self):
+ self.assertEqual(nformat(Decimal('1234'), '.'), '1234')
+ self.assertEqual(nformat(Decimal('1234.2'), '.'), '1234.2')
+ self.assertEqual(nformat(Decimal('1234'), '.', decimal_pos=2), '1234.00')
+ self.assertEqual(nformat(Decimal('1234'), '.', grouping=2, thousand_sep=','), '1234')
+ self.assertEqual(nformat(Decimal('1234'), '.', grouping=2, thousand_sep=',', force_grouping=True), '12,34')
+ self.assertEqual(nformat(Decimal('-1234.33'), '.', decimal_pos=1), '-1234.3')
+ self.assertEqual(nformat(Decimal('0.00000001'), '.', decimal_pos=8), '0.00000001')