diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2022-10-15 21:40:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-15 11:40:22 -0700 |
commit | b7dd2cad186e44e2b481f4518be62f34c682ea59 (patch) | |
tree | e350e11c21257070d19062abd88b5c89946f3aee /Lib/test/string_tests.py | |
parent | f4370318d67f1f2f686c1c3a4b217ccc461d31e5 (diff) | |
download | cpython-b7dd2cad186e44e2b481f4518be62f34c682ea59.tar.gz cpython-b7dd2cad186e44e2b481f4518be62f34c682ea59.zip |
gh-94808: Cover `str.rsplit` for UCS1, UCS2 or UCS4 (#98228)
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r-- | Lib/test/string_tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index e998146c190..709cac7a27a 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -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'], |