diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-31 06:15:51 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-31 06:15:51 (GMT) |
commit | d4ea03c785d659576e0ae65c12fe5c03ada872d0 (patch) | |
tree | f1df6f933651ff70bb27a72f3cf518ed406844b9 /Lib | |
parent | 3d4a457663d5b211e9357bd2ccfd60e0b5d9e57b (diff) | |
download | cpython-d4ea03c785d659576e0ae65c12fe5c03ada872d0.zip cpython-d4ea03c785d659576e0ae65c12fe5c03ada872d0.tar.gz cpython-d4ea03c785d659576e0ae65c12fe5c03ada872d0.tar.bz2 |
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.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/string_tests.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index 6e26474..e086994 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -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) |