gh-94808: Cover str.rsplit for UCS1, UCS2 or UCS4 (#98228)

This commit is contained in:
Nikita Sobolev 2022-10-15 21:40:22 +03:00 committed by GitHub
parent f4370318d6
commit b7dd2cad18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -505,6 +505,11 @@ class BaseTest:
self.checkraises(ValueError, 'hello', 'split', '', 0)
def test_rsplit(self):
# without arg
self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit')
self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit')
self.checkequal([], '', 'rsplit')
# by a char
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|')
self.checkequal(['a|b|c', 'd'], 'a|b|c|d', 'rsplit', '|', 1)
@ -558,6 +563,9 @@ class BaseTest:
# with keyword args
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', sep='|')
self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', sep=None)
self.checkequal(['a b c', 'd'],
'a b c d', 'rsplit', sep=None, maxsplit=1)
self.checkequal(['a|b|c', 'd'],
'a|b|c|d', 'rsplit', '|', maxsplit=1)
self.checkequal(['a|b|c', 'd'],