summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2002-04-15 13:36:47 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2002-04-15 13:36:47 (GMT)
commit068325ef926538a30d7feb13f9b14a6163e24b6e (patch)
treec2eef78d030be1ce7a56b56420ba13a853aab57d /Lib/test
parentb384c7263928cc2d8dd16cac8537839673cd4982 (diff)
downloadcpython-068325ef926538a30d7feb13f9b14a6163e24b6e.zip
cpython-068325ef926538a30d7feb13f9b14a6163e24b6e.tar.gz
cpython-068325ef926538a30d7feb13f9b14a6163e24b6e.tar.bz2
Apply the second version of SF patch http://www.python.org/sf/536241
Add a method zfill to str, unicode and UserString and change Lib/string.py accordingly. This activates the zfill version in unicodeobject.c that was commented out and implements the same in stringobject.c. It also adds the test for unicode support in Lib/string.py back in and uses repr() instead() of str() (as it was before Lib/string.py 1.62)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/string_tests.py10
-rw-r--r--Lib/test/test_unicode.py14
2 files changed, 22 insertions, 2 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 5c8dd93..ea25983 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -227,6 +227,16 @@ def run_method_tests(test):
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)
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 4b77e75..29dd819 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -206,8 +206,18 @@ if 0:
test('capwords', u'abc\tdef\nghi', u'Abc Def Ghi')
test('capwords', u'abc\t def \nghi', u'Abc Def Ghi')
-verify(string.zfill(u'34', 1) == u'34')
-verify(string.zfill(u'34', 5) == u'00034')
+test('zfill', u'123', u'123', 2)
+test('zfill', u'123', u'123', 3)
+test('zfill', u'123', u'0123', 4)
+test('zfill', u'+123', u'+123', 3)
+test('zfill', u'+123', u'+123', 4)
+test('zfill', u'+123', u'+0123', 5)
+test('zfill', u'-123', u'-123', 3)
+test('zfill', u'-123', u'-123', 4)
+test('zfill', u'-123', u'-0123', 5)
+test('zfill', u'', u'000', 3)
+test('zfill', u'34', u'34', 1)
+test('zfill', u'34', u'00034', 5)
# Comparisons:
print 'Testing Unicode comparisons...',