mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	gh-94808: Cover str.rsplit for UCS1, UCS2 or UCS4 (#98228)
				
					
				
			This commit is contained in:
		
							parent
							
								
									f4370318d6
								
							
						
					
					
						commit
						b7dd2cad18
					
				
					 2 changed files with 14 additions and 2 deletions
				
			
		|  | @ -505,6 +505,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) | ||||
|  | @ -558,6 +563,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'], | ||||
|  |  | |||
|  | @ -445,10 +445,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], | ||||
|  | @ -458,6 +458,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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nikita Sobolev
						Nikita Sobolev