diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-02-26 07:39:55 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-02-26 07:39:55 (GMT) |
commit | cda6b6d60d96e6f755da92deb5e4066839095791 (patch) | |
tree | 0835098963d975f54d46707bae270e08df2fc4fa /Lib/test/string_tests.py | |
parent | 408026c7e8c019cf04372a4267c832241e18c62c (diff) | |
download | cpython-cda6b6d60d96e6f755da92deb5e4066839095791.zip cpython-cda6b6d60d96e6f755da92deb5e4066839095791.tar.gz cpython-cda6b6d60d96e6f755da92deb5e4066839095791.tar.bz2 |
#14081: The sep and maxsplit parameter to str.split, bytes.split, and bytearray.split may now be passed as keyword arguments.
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r-- | Lib/test/string_tests.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index feeb4ce..b7246eb 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -56,7 +56,7 @@ class BaseTest(unittest.TestCase): result = self.fixtype(result) obj = self.fixtype(obj) args = self.fixtype(args) - kwargs = self.fixtype(kwargs) + kwargs = {k: self.fixtype(v) for k,v in kwargs.items()} realresult = getattr(obj, methodname)(*args, **kwargs) self.assertEqual( result, @@ -389,6 +389,17 @@ class BaseTest(unittest.TestCase): self.checkequal(['a']*18 + ['aBLAHa'], ('aBLAH'*20)[:-4], 'split', 'BLAH', 18) + # with keyword args + self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', sep='|') + self.checkequal(['a', 'b|c|d'], + 'a|b|c|d', 'split', '|', maxsplit=1) + self.checkequal(['a', 'b|c|d'], + 'a|b|c|d', 'split', sep='|', maxsplit=1) + self.checkequal(['a', 'b|c|d'], + 'a|b|c|d', 'split', maxsplit=1, sep='|') + self.checkequal(['a', 'b c d'], + 'a b c d', 'split', maxsplit=1) + # argument type self.checkraises(TypeError, 'hello', 'split', 42, 42, 42) @@ -446,6 +457,17 @@ class BaseTest(unittest.TestCase): self.checkequal(['aBLAHa'] + ['a']*18, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH', 18) + # 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', '|', maxsplit=1) + self.checkequal(['a|b|c', 'd'], + 'a|b|c|d', 'rsplit', sep='|', maxsplit=1) + self.checkequal(['a|b|c', 'd'], + 'a|b|c|d', 'rsplit', maxsplit=1, sep='|') + self.checkequal(['a b c', 'd'], + 'a b c d', 'rsplit', maxsplit=1) + # argument type self.checkraises(TypeError, 'hello', 'rsplit', 42, 42, 42) |