summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2008-07-16 00:11:49 (GMT)
committerEric Smith <eric@trueblade.com>2008-07-16 00:11:49 (GMT)
commita5fa5a218d3f37485384948a1033fa5a73c2895c (patch)
tree9b57d3c4cd78556473fcbe6ee541d81fa2280ac8 /Lib
parent954a27893951b49e94654b5d20bee606f82d37c6 (diff)
downloadcpython-a5fa5a218d3f37485384948a1033fa5a73c2895c.zip
cpython-a5fa5a218d3f37485384948a1033fa5a73c2895c.tar.gz
cpython-a5fa5a218d3f37485384948a1033fa5a73c2895c.tar.bz2
Complete issue 3083: add alternate (#) formatting to bin, oct, hex in str.format().
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_types.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index b185479..03f2ff8 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -365,7 +365,8 @@ class TypesTests(unittest.TestCase):
test(-1, "-#5b", ' -0b1')
test(1, "+#5b", ' +0b1')
test(100, "+#b", '+0b1100100')
-# test(100, "#012b", '0b001100100')
+ test(100, "#012b", '0b0001100100')
+ test(-100, "#012b", '-0b001100100')
test(0, "#o", '0o0')
test(0, "-#o", '0o0')
@@ -374,6 +375,8 @@ class TypesTests(unittest.TestCase):
test(-1, "-#5o", ' -0o1')
test(1, "+#5o", ' +0o1')
test(100, "+#o", '+0o144')
+ test(100, "#012o", '0o0000000144')
+ test(-100, "#012o", '-0o000000144')
test(0, "#x", '0x0')
test(0, "-#x", '0x0')
@@ -382,6 +385,10 @@ class TypesTests(unittest.TestCase):
test(-1, "-#5x", ' -0x1')
test(1, "+#5x", ' +0x1')
test(100, "+#x", '+0x64')
+ test(100, "#012x", '0x0000000064')
+ test(-100, "#012x", '-0x000000064')
+ test(123456, "#012x", '0x000001e240')
+ test(-123456, "#012x", '-0x00001e240')
test(0, "#X", '0X0')
test(0, "-#X", '0X0')
@@ -390,6 +397,10 @@ class TypesTests(unittest.TestCase):
test(-1, "-#5X", ' -0X1')
test(1, "+#5X", ' +0X1')
test(100, "+#X", '+0X64')
+ test(100, "#012X", '0X0000000064')
+ test(-100, "#012X", '-0X000000064')
+ test(123456, "#012X", '0X000001E240')
+ test(-123456, "#012X", '-0X00001E240')
# make sure these are errors