mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
Issue #24284: The startswith and endswith methods of the str class no longer
return True when finding the empty string and the indexes are completely out of range.
This commit is contained in:
parent
3d4a457663
commit
d4ea03c785
4 changed files with 17 additions and 3 deletions
|
@ -976,6 +976,9 @@ class MixinStrUnicodeUserStringTest:
|
|||
self.checkequal(True, 'helloworld', 'startswith', 'lowo', 3)
|
||||
self.checkequal(True, 'helloworld', 'startswith', 'lowo', 3, 7)
|
||||
self.checkequal(False, 'helloworld', 'startswith', 'lowo', 3, 6)
|
||||
self.checkequal(True, '', 'startswith', '', 0, 1)
|
||||
self.checkequal(True, '', 'startswith', '', 0, 0)
|
||||
self.checkequal(False, '', 'startswith', '', 1, 0)
|
||||
|
||||
# test negative indices
|
||||
self.checkequal(True, 'hello', 'startswith', 'he', 0, -1)
|
||||
|
@ -1022,6 +1025,9 @@ class MixinStrUnicodeUserStringTest:
|
|||
self.checkequal(False, 'helloworld', 'endswith', 'lowo', 3, 8)
|
||||
self.checkequal(False, 'ab', 'endswith', 'ab', 0, 1)
|
||||
self.checkequal(False, 'ab', 'endswith', 'ab', 0, 0)
|
||||
self.checkequal(True, '', 'endswith', '', 0, 1)
|
||||
self.checkequal(True, '', 'endswith', '', 0, 0)
|
||||
self.checkequal(False, '', 'endswith', '', 1, 0)
|
||||
|
||||
# test negative indices
|
||||
self.checkequal(True, 'hello', 'endswith', 'lo', -2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue