diff Lib/test/string_tests.py @ 23219:b08b51dce264 2.2

Backport the following changes: Misc/NEWS 1.387->1.388 Lib/test/string_tests.py 1.10->1.11, 1.12->1.14, Lib/test/test_unicode.py 1.50->1.51, 1.53->1.54, 1.55->1.56 Lib/test/test_string.py 1.15->1.16 Lib/string.py 1.61->1.63 Lib/test/test_userstring.py 1.5->1.6, 1.11, 1.12 Objects/stringobject.c 2.156->2.159 Objects/unicodeobject.c 2.137->2.139 Doc/lib/libstdtypes.tec 1.87->1.88 Add a method zfill to str, unicode and UserString and change Lib/string.py accordingly (see SF patch http://www.python.org/sf/536241) This also adds Guido's fix to test_userstring.py and the subinstance checks in test_string.py and test_unicode.py.
author Walter Dörwald <walter@livinglogic.de>
date Mon, 22 Apr 2002 11:57:06 +0000
parents 0ecef8bfbd4b
children dd350b639309
line wrap: on
line diff
--- a/Lib/test/string_tests.py	Mon Apr 22 11:21:59 2002 +0000
+++ b/Lib/test/string_tests.py	Mon Apr 22 11:57:06 2002 +0000
@@ -227,6 +227,19 @@
     test('endswith', 'ab', 0, 'ab', 0, 1)
     test('endswith', 'ab', 0, 'ab', 0, 0)
 
+    test('zfill', '123', '123', 2)
+    test('zfill', '123', '123', 3)
+    test('zfill', '123', '0123', 4)
+    test('zfill', '+123', '+123', 3)
+    test('zfill', '+123', '+123', 4)
+    test('zfill', '+123', '+0123', 5)
+    test('zfill', '-123', '-123', 3)
+    test('zfill', '-123', '-123', 4)
+    test('zfill', '-123', '-0123', 5)
+    test('zfill', '', '000', 3)
+    test('zfill', '34', '34', 1)
+    test('zfill', '34', '0034', 4)
+
     # Encoding/decoding
     codecs = [('rot13', 'uryyb jbeyq'),
               ('base64', 'aGVsbG8gd29ybGQ=\n'),