summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2010-02-23 00:11:16 (GMT)
committerEric Smith <eric@trueblade.com>2010-02-23 00:11:16 (GMT)
commit87bcb243acfd758b3e91e194bf8f1198ae68a792 (patch)
treee393d282de49af07290f30c16e5a067aac76caf6 /Lib/test
parentae3db0a12b0c5ca42ea9fe54161d56c57269ea92 (diff)
downloadcpython-87bcb243acfd758b3e91e194bf8f1198ae68a792.zip
cpython-87bcb243acfd758b3e91e194bf8f1198ae68a792.tar.gz
cpython-87bcb243acfd758b3e91e194bf8f1198ae68a792.tar.bz2
Issue #6902: Fix problem with built-in types format incorrectly with 0 padding.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_types.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index 498f73a..e4b4b5b 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -435,6 +435,17 @@ class TypesTests(unittest.TestCase):
self.assertEqual(value.__format__(format_spec),
float(value).__format__(format_spec))
+ # Issue 6902
+ test(123456, "0<20", '12345600000000000000')
+ test(123456, "1<20", '12345611111111111111')
+ test(123456, "*<20", '123456**************')
+ test(123456, "0>20", '00000000000000123456')
+ test(123456, "1>20", '11111111111111123456')
+ test(123456, "*>20", '**************123456')
+ test(123456, "0=20", '00000000000000123456')
+ test(123456, "1=20", '11111111111111123456')
+ test(123456, "*=20", '**************123456')
+
def test_long__format__(self):
def test(i, format_spec, result):
# make sure we're not accidentally checking ints
@@ -532,6 +543,16 @@ class TypesTests(unittest.TestCase):
for value in [0L, 1L, -1L, 100L, -100L, 1234567890L, -1234567890L]:
self.assertEqual(value.__format__(format_spec),
float(value).__format__(format_spec))
+ # Issue 6902
+ test(123456L, "0<20", '12345600000000000000')
+ test(123456L, "1<20", '12345611111111111111')
+ test(123456L, "*<20", '123456**************')
+ test(123456L, "0>20", '00000000000000123456')
+ test(123456L, "1>20", '11111111111111123456')
+ test(123456L, "*>20", '**************123456')
+ test(123456L, "0=20", '00000000000000123456')
+ test(123456L, "1=20", '11111111111111123456')
+ test(123456L, "*=20", '**************123456')
@run_with_locale('LC_NUMERIC', 'en_US.UTF8')
def test_float__format__locale(self):
@@ -689,6 +710,17 @@ class TypesTests(unittest.TestCase):
self.assertRaises(ValueError, format, 0.0, '#')
self.assertRaises(ValueError, format, 0.0, '#20f')
+ # Issue 6902
+ test(12345.6, "0<20", '12345.60000000000000')
+ test(12345.6, "1<20", '12345.61111111111111')
+ test(12345.6, "*<20", '12345.6*************')
+ test(12345.6, "0>20", '000000000000012345.6')
+ test(12345.6, "1>20", '111111111111112345.6')
+ test(12345.6, "*>20", '*************12345.6')
+ test(12345.6, "0=20", '000000000000012345.6')
+ test(12345.6, "1=20", '111111111111112345.6')
+ test(12345.6, "*=20", '*************12345.6')
+
def test_format_spec_errors(self):
# int, float, and string all share the same format spec
# mini-language parser.