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.
........
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 @@
                 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)