diff options
author | Eric Smith <eric@trueblade.com> | 2008-04-30 02:12:09 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2008-04-30 02:12:09 (GMT) |
commit | b2c7af82211ac32295b9419f359036ccb4e819a7 (patch) | |
tree | b9287cf4c62ffc5e4d511e2b713e1b1c8d6ce632 /Lib | |
parent | c14bb758b2f4111ab4f095d8fe2b6981bd05b185 (diff) | |
download | cpython-b2c7af82211ac32295b9419f359036ccb4e819a7.zip cpython-b2c7af82211ac32295b9419f359036ccb4e819a7.tar.gz cpython-b2c7af82211ac32295b9419f359036ccb4e819a7.tar.bz2 |
Merged revisions 62586 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62586 | eric.smith | 2008-04-29 21:09:30 -0400 (Tue, 29 Apr 2008) | 5 lines
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 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) |