[Python-checkins] python/dist/src/Lib/test string_tests.py,1.30,1.31
nnorwitz@users.sourceforge.net
nnorwitz@users.sourceforge.net
Thu, 10 Apr 2003 15:35:34 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv20253/Lib/test
Modified Files:
string_tests.py
Log Message:
Attempt to make all the various string *strip methods the same.
* Doc - add doc for when functions were added
* UserString
* string object methods
* string module functions
'chars' is used for the last parameter everywhere.
These changes will be backported, since part of the changes
have already been made, but they were inconsistent.
Index: string_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** string_tests.py 31 Mar 2003 18:07:50 -0000 1.30
--- string_tests.py 10 Apr 2003 22:35:31 -0000 1.31
***************
*** 196,199 ****
--- 196,226 ----
self.checkequal('hello', 'hello', 'strip')
+ # strip/lstrip/rstrip with None arg
+ self.checkequal('hello', ' hello ', 'strip', None)
+ self.checkequal('hello ', ' hello ', 'lstrip', None)
+ self.checkequal(' hello', ' hello ', 'rstrip', None)
+ self.checkequal('hello', 'hello', 'strip', None)
+
+ # strip/lstrip/rstrip with str arg
+ self.checkequal('hello', 'xyzzyhelloxyzzy', 'strip', 'xyz')
+ self.checkequal('helloxyzzy', 'xyzzyhelloxyzzy', 'lstrip', 'xyz')
+ self.checkequal('xyzzyhello', 'xyzzyhelloxyzzy', 'rstrip', 'xyz')
+ self.checkequal('hello', 'hello', 'strip', 'xyz')
+
+ # strip/lstrip/rstrip with unicode arg
+ if test_support.have_unicode:
+ self.checkequal(unicode('hello', 'ascii'), 'xyzzyhelloxyzzy',
+ 'strip', unicode('xyz', 'ascii'))
+ self.checkequal(unicode('helloxyzzy', 'ascii'), 'xyzzyhelloxyzzy',
+ 'lstrip', unicode('xyz', 'ascii'))
+ self.checkequal(unicode('xyzzyhello', 'ascii'), 'xyzzyhelloxyzzy',
+ 'rstrip', unicode('xyz', 'ascii'))
+ self.checkequal(unicode('hello', 'ascii'), 'hello',
+ 'strip', unicode('xyz', 'ascii'))
+
+ self.checkraises(TypeError, 'hello', 'strip', 42, 42)
+ self.checkraises(TypeError, 'hello', 'lstrip', 42, 42)
+ self.checkraises(TypeError, 'hello', 'rstrip', 42, 42)
+
def test_ljust(self):
self.checkequal('abc ', 'abc', 'ljust', 10)
***************
*** 432,463 ****
self.checkraises(TypeError, 'hello', 'endswith')
self.checkraises(TypeError, 'hello', 'endswith', 42)
-
- def test_strip_args(self):
- # strip/lstrip/rstrip with None arg
- self.checkequal('hello', ' hello ', 'strip', None)
- self.checkequal('hello ', ' hello ', 'lstrip', None)
- self.checkequal(' hello', ' hello ', 'rstrip', None)
- self.checkequal('hello', 'hello', 'strip', None)
-
- # strip/lstrip/rstrip with str arg
- self.checkequal('hello', 'xyzzyhelloxyzzy', 'strip', 'xyz')
- self.checkequal('helloxyzzy', 'xyzzyhelloxyzzy', 'lstrip', 'xyz')
- self.checkequal('xyzzyhello', 'xyzzyhelloxyzzy', 'rstrip', 'xyz')
- self.checkequal('hello', 'hello', 'strip', 'xyz')
-
- # strip/lstrip/rstrip with unicode arg
- if test_support.have_unicode:
- self.checkequal(unicode('hello', 'ascii'), 'xyzzyhelloxyzzy',
- 'strip', unicode('xyz', 'ascii'))
- self.checkequal(unicode('helloxyzzy', 'ascii'), 'xyzzyhelloxyzzy',
- 'lstrip', unicode('xyz', 'ascii'))
- self.checkequal(unicode('xyzzyhello', 'ascii'), 'xyzzyhelloxyzzy',
- 'rstrip', unicode('xyz', 'ascii'))
- self.checkequal(unicode('hello', 'ascii'), 'hello',
- 'strip', unicode('xyz', 'ascii'))
-
- self.checkraises(TypeError, 'hello', 'strip', 42, 42)
- self.checkraises(TypeError, 'hello', 'lstrip', 42, 42)
- self.checkraises(TypeError, 'hello', 'rstrip', 42, 42)
def test___contains__(self):
--- 459,462 ----