Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2c7af8

Browse files
committed
Merged revisions 62586 via svnmerge from
svn+ssh://[email protected]/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. ........
1 parent c14bb75 commit b2c7af8

2 files changed

Lines changed: 240 additions & 129 deletions

File tree

Lib/test/test_types.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Python test set -- part 6, built-in types
22

3-
from test.test_support import run_unittest
3+
from test.test_support import run_unittest, run_with_locale
44
import unittest
55
import sys
6+
import locale
67

78
class TypesTests(unittest.TestCase):
89

@@ -407,6 +408,15 @@ def test(i, format_spec, result):
407408
self.assertEqual(value.__format__(format_spec),
408409
float(value).__format__(format_spec))
409410

411+
@run_with_locale('LC_NUMERIC', 'en_US.UTF8')
412+
def test_float__format__locale(self):
413+
# test locale support for __format__ code 'n'
414+
415+
for i in range(-10, 10):
416+
x = 1234567890.0 * (10.0 ** i)
417+
self.assertEqual(locale.format('%g', x, grouping=True), format(x, 'n'))
418+
self.assertEqual(locale.format('%.10g', x, grouping=True), format(x, '.10n'))
419+
410420
def test_float__format__(self):
411421
# these should be rewritten to use both format(x, spec) and
412422
# x.__format__(spec)

0 commit comments

Comments
 (0)