summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1999-06-11 17:48:07 (GMT)
committerBarry Warsaw <barry@python.org>1999-06-11 17:48:07 (GMT)
commit8a9514a66015f6f01ee0678707d1668cddfb6e7b (patch)
treea40373df92825b9e945c8626db0c7f25aaa41f8b /Lib
parent13205609c59845fa37c455839b0ec0030588465b (diff)
downloadcpython-8a9514a66015f6f01ee0678707d1668cddfb6e7b.zip
cpython-8a9514a66015f6f01ee0678707d1668cddfb6e7b.tar.gz
cpython-8a9514a66015f6f01ee0678707d1668cddfb6e7b.tar.bz2
Harness can now test object methods directly, if they aren't available
in the string module. Add a bunch of new tests for extended startswith/endswith arguments.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_string.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py
index d5ea178..2fa9dd5 100644
--- a/Lib/test/test_string.py
+++ b/Lib/test/test_string.py
@@ -4,9 +4,13 @@ import string, sys
def test(name, input, output, *args):
if verbose:
print 'string.%s%s =? %s... ' % (name, (input,) + args, output),
- f = getattr(string, name)
try:
- value = apply(f, (input,) + args)
+ try:
+ f = getattr(string, name)
+ value = apply(f, (input,) + args)
+ except AttributeError:
+ f = getattr(input, name)
+ value = apply(f, args)
except:
value = sys.exc_type
if value != output:
@@ -104,6 +108,14 @@ test('endswith', 'hello', 1, 'lo')
test('endswith', 'hello', 0, 'he')
test('endswith', 'hello', 1, '')
test('endswith', 'hello', 0, 'hello world')
+test('endswith', 'helloworld', 0, 'worl')
+test('endswith', 'helloworld', 1, 'worl', 3, 9)
+test('endswith', 'helloworld', 1, 'world', 3, 12)
+test('endswith', 'helloworld', 1, 'lowo', 1, 7)
+test('endswith', 'helloworld', 1, 'lowo', 2, 7)
+test('endswith', 'helloworld', 1, 'lowo', 3, 7)
+test('endswith', 'helloworld', 0, 'lowo', 4, 7)
+test('endswith', 'helloworld', 0, 'lowo', 3, 8)
string.whitespace
string.lowercase