diff options
author | Eric Smith <eric@trueblade.com> | 2008-04-30 01:09:30 +0000 |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2008-04-30 01:09:30 +0000 |
commit | 0a95063d732b6f309a0cbf73e6095fb8774e5914 (patch) | |
tree | 02c3fe7a69952ede0e1defc4ad308265fd17be80 /Lib | |
parent | 48f6276ddc924cebba646ac2c7e108f2c8bc4a2f (diff) | |
download | cpython-git-0a95063d732b6f309a0cbf73e6095fb8774e5914.tar.gz |
Issue 2526, float.__format__ 'n' specifier does not support thousands grouping.
Implemented grouping, with tests.
Cleaned up PyOS_ascii_formatd by breaking reformatting into smaller functions.
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 4fa2c01926..4b620c509f 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, have_unicode +from test.test_support import run_unittest, have_unicode, run_with_locale import unittest import sys +import locale class TypesTests(unittest.TestCase): @@ -476,6 +477,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) |