[Python-checkins] python/dist/src/Lib/test string_tests.py, 1.34, 1.35

perky at users.sourceforge.net perky at users.sourceforge.net
Mon Dec 15 13:49:21 EST 2003


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv28695/Lib/test

Modified Files:
	string_tests.py 
Log Message:
Add rsplit method for str and unicode builtin types.  

SF feature request #801847.
Original patch is written by Sean Reifschneider.


Index: string_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** string_tests.py	26 Nov 2003 08:21:34 -0000	1.34
--- string_tests.py	15 Dec 2003 18:49:19 -0000	1.35
***************
*** 190,193 ****
--- 190,213 ----
          self.checkraises(TypeError, 'hello', 'split', 42, 42, 42)
  
+     def test_rsplit(self):
+         self.checkequal(['this', 'is', 'the', 'rsplit', 'function'],
+                          'this is the rsplit function', 'rsplit')
+         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|')
+         self.checkequal(['a|b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 2)
+         self.checkequal(['a b c', 'd'], 'a b c d', 'rsplit', None, 1)
+         self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2)
+         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 3)
+         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 4)
+         self.checkequal(['a b c d'], 'a b c d', 'rsplit', None, 0)
+         self.checkequal(['a, b, c', 'd'], 'a, b, c, d', 'rsplit', ', ', 1)
+         self.checkequal(['a, b', 'c', 'd'], 'a, b, c, d', 'rsplit', ', ', 2)
+         self.checkequal(['a', 'b', 'c', 'd'], 'a, b, c, d', 'rsplit', ', ', 3)
+         self.checkequal(['a', 'b', 'c', 'd'], 'a, b, c, d', 'rsplit', ', ', 4)
+         self.checkequal(['a, b, c, d'], 'a, b, c, d', 'rsplit', ', ', 0)
+         self.checkequal(['a  b', 'c', 'd'], 'a  b  c  d', 'rsplit', None, 2)
+         self.checkequal(['a\x00b', 'c'], 'a\x00b\x00c', 'rsplit', '\x00', 1)
+         self.checkequal(['', ''], 'abcd', 'rsplit', 'abcd')
+         self.checkequal([u'a b', u'c', u'd'], 'a b c d', 'rsplit', u' ', 2)
+ 
      def test_strip(self):
          self.checkequal('hello', '   hello   ', 'strip')





More information about the Python-checkins mailing list