diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_types.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index dae250e..1c7a8cd 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -1,8 +1,9 @@ # Python test set -- part 6, built-in types -from test.test_support import run_unittest +from test.test_support import run_unittest, run_with_locale import unittest import sys +import locale class TypesTests(unittest.TestCase): @@ -407,6 +408,15 @@ class TypesTests(unittest.TestCase): self.assertEqual(value.__format__(format_spec), float(value).__format__(format_spec)) + @run_with_locale('LC_NUMERIC', 'en_US.UTF8') + def test_float__format__locale(self): + # test locale support for __format__ code 'n' + + for i in range(-10, 10): + x = 1234567890.0 * (10.0 ** i) + self.assertEqual(locale.format('%g', x, grouping=True), format(x, 'n')) + self.assertEqual(locale.format('%.10g', x, grouping=True), format(x, '.10n')) + def test_float__format__(self): # these should be rewritten to use both format(x, spec) and # x.__format__(spec) |