[Python-checkins] [3.11] gh-94808: Cover `str.rsplit` for UCS1, UCS2 or UCS4 (GH-98228) (#98291)
JelleZijlstra
webhook-mailer at python.org
Wed Oct 19 20:53:56 EDT 2022
https://github.com/python/cpython/commit/df4aaff0e60e907225370755bb9881b08fb2b0ea
commit: df4aaff0e60e907225370755bb9881b08fb2b0ea
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-10-19T17:53:50-07:00
summary:
[3.11] gh-94808: Cover `str.rsplit` for UCS1, UCS2 or UCS4 (GH-98228) (#98291)
gh-94808: Cover `str.rsplit` for UCS1, UCS2 or UCS4 (GH-98228)
(cherry picked from commit b7dd2cad186e44e2b481f4518be62f34c682ea59)
Co-authored-by: Nikita Sobolev <mail at sobolevn.me>
files:
M Lib/test/string_tests.py
M Lib/test/test_unicode.py
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 0d4c7ecf4a04..d69edd7bf458 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -469,6 +469,11 @@ def test_split(self):
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)
@@ -522,6 +527,9 @@ def test_rsplit(self):
# 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'],
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 9b0e4b230506..60e5b1902cf6 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -441,10 +441,10 @@ def test_split(self):
def test_rsplit(self):
string_tests.CommonTest.test_rsplit(self)
# test mixed kinds
- for left, right in ('ba', '\u0101\u0100', '\U00010301\U00010300'):
+ for left, right in ('ba', 'юё', '\u0101\u0100', '\U00010301\U00010300'):
left *= 9
right *= 9
- for delim in ('c', '\u0102', '\U00010302'):
+ for delim in ('c', 'ы', '\u0102', '\U00010302'):
self.checkequal([left + right],
left + right, 'rsplit', delim)
self.checkequal([left, right],
@@ -454,6 +454,10 @@ def test_rsplit(self):
self.checkequal([left, right],
left + delim * 2 + right, 'rsplit', delim *2)
+ # Check `None` as well:
+ self.checkequal([left + right],
+ left + right, 'rsplit', None)
+
def test_partition(self):
string_tests.MixinStrUnicodeUserStringTest.test_partition(self)
# test mixed kinds
More information about the Python-checkins
mailing list