diff options
author | Walter Dörwald <walter@livinglogic.de> | 2002-04-22 17:42:37 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2002-04-22 17:42:37 (GMT) |
commit | de02bcb2659af6acb1d44ba61c0bcf7b2d53a6ed (patch) | |
tree | bcb24d906dccf9dfd69b2f1eb69c911d68cdba45 /Lib | |
parent | a7cc43b9e8b55223ad6b711488fbe8c10df6b5c2 (diff) | |
download | cpython-de02bcb2659af6acb1d44ba61c0bcf7b2d53a6ed.zip cpython-de02bcb2659af6acb1d44ba61c0bcf7b2d53a6ed.tar.gz cpython-de02bcb2659af6acb1d44ba61c0bcf7b2d53a6ed.tar.bz2 |
Apply patch diff.txt from SF feature request
http://www.python.org/sf/444708
This adds the optional argument for str.strip
to unicode.strip too and makes it possible
to call str.strip with a unicode argument
and unicode.strip with a str argument.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/string_tests.py | 8 | ||||
-rw-r--r-- | Lib/test/test_unicode.py | 18 |
2 files changed, 25 insertions, 1 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index 180072c..4185b9b 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -169,12 +169,18 @@ def run_method_tests(test): test('rstrip', ' hello ', ' hello', None) test('strip', 'hello', 'hello', None) - # strip/lstrip/rstrip with real arg + # strip/lstrip/rstrip with str arg test('strip', 'xyzzyhelloxyzzy', 'hello', 'xyz') test('lstrip', 'xyzzyhelloxyzzy', 'helloxyzzy', 'xyz') test('rstrip', 'xyzzyhelloxyzzy', 'xyzzyhello', 'xyz') test('strip', 'hello', 'hello', 'xyz') + # strip/lstrip/rstrip with unicode arg + test('strip', 'xyzzyhelloxyzzy', u'hello', u'xyz') + test('lstrip', 'xyzzyhelloxyzzy', u'helloxyzzy', u'xyz') + test('rstrip', 'xyzzyhelloxyzzy', u'xyzzyhello', u'xyz') + test('strip', 'hello', u'hello', u'xyz') + test('swapcase', 'HeLLo cOmpUteRs', 'hEllO CoMPuTErS') test('translate', 'xyzabcdef', 'xyzxyz', transtable, 'def') diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 8e8ddf9..5d73939 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -169,6 +169,24 @@ test('lstrip', u' hello ', u'hello ') test('rstrip', u' hello ', u' hello') test('strip', u'hello', u'hello') +# strip/lstrip/rstrip with None arg +test('strip', u' hello ', u'hello', None) +test('lstrip', u' hello ', u'hello ', None) +test('rstrip', u' hello ', u' hello', None) +test('strip', u'hello', u'hello', None) + +# strip/lstrip/rstrip with unicode arg +test('strip', u'xyzzyhelloxyzzy', u'hello', u'xyz') +test('lstrip', u'xyzzyhelloxyzzy', u'helloxyzzy', u'xyz') +test('rstrip', u'xyzzyhelloxyzzy', u'xyzzyhello', u'xyz') +test('strip', u'hello', u'hello', u'xyz') + +# strip/lstrip/rstrip with str arg +test('strip', u'xyzzyhelloxyzzy', u'hello', 'xyz') +test('lstrip', u'xyzzyhelloxyzzy', u'helloxyzzy', 'xyz') +test('rstrip', u'xyzzyhelloxyzzy', u'xyzzyhello', 'xyz') +test('strip', u'hello', u'hello', 'xyz') + test('swapcase', u'HeLLo cOmpUteRs', u'hEllO CoMPuTErS') if 0: |