We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
str.rsplit
1 parent f437031 commit b7dd2caCopy full SHA for b7dd2ca
Lib/test/string_tests.py
@@ -505,6 +505,11 @@ def test_split(self):
505
self.checkraises(ValueError, 'hello', 'split', '', 0)
506
507
def test_rsplit(self):
508
+ # without arg
509
+ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit')
510
511
+ self.checkequal([], '', 'rsplit')
512
+
513
# by a char
514
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|')
515
self.checkequal(['a|b|c', 'd'], 'a|b|c|d', 'rsplit', '|', 1)
@@ -558,6 +563,9 @@ def test_rsplit(self):
558
563
559
564
# with keyword args
560
565
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', sep='|')
566
+ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', sep=None)
567
+ self.checkequal(['a b c', 'd'],
568
+ 'a b c d', 'rsplit', sep=None, maxsplit=1)
561
569
self.checkequal(['a|b|c', 'd'],
562
570
'a|b|c|d', 'rsplit', '|', maxsplit=1)
571
Lib/test/test_unicode.py
@@ -445,10 +445,10 @@ def test_split(self):
445
446
string_tests.CommonTest.test_rsplit(self)
447
# test mixed kinds
448
- for left, right in ('ba', '\u0101\u0100', '\U00010301\U00010300'):
+ for left, right in ('ba', 'юё', '\u0101\u0100', '\U00010301\U00010300'):
449
left *= 9
450
right *= 9
451
- for delim in ('c', '\u0102', '\U00010302'):
+ for delim in ('c', 'ы', '\u0102', '\U00010302'):
452
self.checkequal([left + right],
453
left + right, 'rsplit', delim)
454
self.checkequal([left, right],
@@ -458,6 +458,10 @@ def test_rsplit(self):
458
459
left + delim * 2 + right, 'rsplit', delim *2)
460
461
+ # Check `None` as well:
462
+ self.checkequal([left + right],
463
+ left + right, 'rsplit', None)
464
465
def test_partition(self):
466
string_tests.MixinStrUnicodeUserStringTest.test_partition(self)
467
0 commit comments