summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_locale.py
diff options
context:
space:
mode:
authorCédric Krier <cedk@users.noreply.github.com>2021-04-12 12:17:40 (GMT)
committerGitHub <noreply@github.com>2021-04-12 12:17:40 (GMT)
commite126547c070fbc080562abb08e16a2c93a8a805d (patch)
treeec2d7f22999855aa870d69891fb476106f2b9fe0 /Lib/test/test_locale.py
parent95bbb331ecb3ef5d05859d90b287cc3d27613c86 (diff)
downloadcpython-e126547c070fbc080562abb08e16a2c93a8a805d.zip
cpython-e126547c070fbc080562abb08e16a2c93a8a805d.tar.gz
cpython-e126547c070fbc080562abb08e16a2c93a8a805d.tar.bz2
bpo-34311: Add locale.localize (GH-15275)
* Add method localize to the locale module * Update the documentation of the locale module
Diffstat (limited to 'Lib/test/test_locale.py')
-rw-r--r--Lib/test/test_locale.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py
index 4bb4c55..2c788f2 100644
--- a/Lib/test/test_locale.py
+++ b/Lib/test/test_locale.py
@@ -1,3 +1,4 @@
+from decimal import Decimal
from test.support import verbose, is_android
from test.support.warnings_helper import check_warnings
import unittest
@@ -636,5 +637,32 @@ class TestfrFRDelocalizeTest(FrFRCookedTest, BaseDelocalizeTest):
self._test_atoi('50 000', 50000)
+class BaseLocalizeTest(BaseLocalizedTest):
+
+ def _test_localize(self, value, out, grouping=False):
+ self.assertEqual(locale.localize(value, grouping=grouping), out)
+
+
+class TestEnUSLocalize(EnUSCookedTest, BaseLocalizeTest):
+
+ def test_localize(self):
+ self._test_localize('50000.00', '50000.00')
+ self._test_localize(
+ '{0:.16f}'.format(Decimal('1.15')), '1.1500000000000000')
+
+
+class TestCLocalize(CCookedTest, BaseLocalizeTest):
+
+ def test_localize(self):
+ self._test_localize('50000.00', '50000.00')
+
+
+class TestfrFRLocalize(FrFRCookedTest, BaseLocalizeTest):
+
+ def test_localize(self):
+ self._test_localize('50000.00', '50000,00')
+ self._test_localize('50000.00', '50 000,00', grouping=True)
+
+
if __name__ == '__main__':
unittest.main()