summaryrefslogtreecommitdiff
path: root/tests/utils_tests/test_numberformat.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2015-03-09 17:56:13 +0100
committerClaude Paroz <claude@2xlibre.net>2015-03-09 18:55:28 +0100
commitdf193b3cefda982dfcd4813bf4e2ac09b1358f21 (patch)
treec8f4f96f2edf7cb772996d7383a283f24ad51e66 /tests/utils_tests/test_numberformat.py
parentea9157f681654d393c970108866edb344b65a1aa (diff)
Fixed #24382 -- Allowed unicode chars inside formatted numbers
Thanks Jacob Rief for the report and Tim Graham for the review.
Diffstat (limited to 'tests/utils_tests/test_numberformat.py')
-rw-r--r--tests/utils_tests/test_numberformat.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/utils_tests/test_numberformat.py b/tests/utils_tests/test_numberformat.py
index 43579060bc..d963bd284b 100644
--- a/tests/utils_tests/test_numberformat.py
+++ b/tests/utils_tests/test_numberformat.py
@@ -1,3 +1,6 @@
+# -*- encoding: utf-8 -*-
+from __future__ import unicode_literals
+
from decimal import Decimal
from sys import float_info
from unittest import TestCase
@@ -59,3 +62,15 @@ class TestNumberFormat(TestCase):
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')
+
+ def test_decimal_subclass(self):
+ class EuroDecimal(Decimal):
+ """
+ Wrapper for Decimal which prefixes each amount with the € symbol.
+ """
+ def __format__(self, specifier, **kwargs):
+ amount = super(EuroDecimal, self).__format__(specifier, **kwargs)
+ return '€ {}'.format(amount)
+
+ price = EuroDecimal('1.23')
+ self.assertEqual(nformat(price, ','), '€ 1,23')