summaryrefslogtreecommitdiffstats
path: root/Lib/test/string_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r--Lib/test/string_tests.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index aaa2dc2..5a1cc8a 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -819,6 +819,21 @@ class MixinStrUnicodeUserStringTest:
self.checkraises(TypeError, 'hello', 'startswith')
self.checkraises(TypeError, 'hello', 'startswith', 42)
+ # test tuple arguments
+ self.checkequal(True, 'hello', 'startswith', ('he', 'ha'))
+ self.checkequal(False, 'hello', 'startswith', ('lo', 'llo'))
+ self.checkequal(True, 'hello', 'startswith', ('hellox', 'hello'))
+ self.checkequal(False, 'hello', 'startswith', ())
+ self.checkequal(True, 'helloworld', 'startswith', ('hellowo',
+ 'rld', 'lowo'), 3)
+ self.checkequal(False, 'helloworld', 'startswith', ('hellowo', 'ello',
+ 'rld'), 3)
+ self.checkequal(True, 'hello', 'startswith', ('lo', 'he'), 0, -1)
+ self.checkequal(False, 'hello', 'startswith', ('he', 'hel'), 0, 1)
+ self.checkequal(True, 'hello', 'startswith', ('he', 'hel'), 0, 2)
+
+ self.checkraises(TypeError, 'hello', 'startswith', (42,))
+
def test_endswith(self):
self.checkequal(True, 'hello', 'endswith', 'lo')
self.checkequal(False, 'hello', 'endswith', 'he')
@@ -853,6 +868,21 @@ class MixinStrUnicodeUserStringTest:
self.checkraises(TypeError, 'hello', 'endswith')
self.checkraises(TypeError, 'hello', 'endswith', 42)
+ # test tuple arguments
+ self.checkequal(False, 'hello', 'endswith', ('he', 'ha'))
+ self.checkequal(True, 'hello', 'endswith', ('lo', 'llo'))
+ self.checkequal(True, 'hello', 'endswith', ('hellox', 'hello'))
+ self.checkequal(False, 'hello', 'endswith', ())
+ self.checkequal(True, 'helloworld', 'endswith', ('hellowo',
+ 'rld', 'lowo'), 3)
+ self.checkequal(False, 'helloworld', 'endswith', ('hellowo', 'ello',
+ 'rld'), 3, -1)
+ self.checkequal(True, 'hello', 'endswith', ('hell', 'ell'), 0, -1)
+ self.checkequal(False, 'hello', 'endswith', ('he', 'hel'), 0, 1)
+ self.checkequal(True, 'hello', 'endswith', ('he', 'hell'), 0, 4)
+
+ self.checkraises(TypeError, 'hello', 'endswith', (42,))
+
def test___contains__(self):
self.checkequal(True, '', '__contains__', '') # vereq('' in '', True)
self.checkequal(True, 'abc', '__contains__', '') # vereq('' in 'abc', True)
@@ -872,7 +902,7 @@ class MixinStrUnicodeUserStringTest:
self.checkequal(u'abc', 'abc', '__getitem__', slice(0, 1000))
self.checkequal(u'a', 'abc', '__getitem__', slice(0, 1))
self.checkequal(u'', 'abc', '__getitem__', slice(0, 0))
- # FIXME What about negative indizes? This is handled differently by [] and __getitem__(slice)
+ # FIXME What about negative indices? This is handled differently by [] and __getitem__(slice)
self.checkraises(TypeError, 'abc', '__getitem__', 'def')