diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2011-09-24 08:14:39 (GMT) |
---|---|---|
committer | Mark Dickinson <mdickinson@enthought.com> | 2011-09-24 08:14:39 (GMT) |
commit | 0d5f6adbb3e5d829a64ef1b431f7ac76dd258c1e (patch) | |
tree | d07d766085d981b7021696af28b0ea7bf4dd8ecc /Lib/test/string_tests.py | |
parent | a61b053e611dd97258231913b79fafe0a9a16125 (diff) | |
download | cpython-0d5f6adbb3e5d829a64ef1b431f7ac76dd258c1e.zip cpython-0d5f6adbb3e5d829a64ef1b431f7ac76dd258c1e.tar.gz cpython-0d5f6adbb3e5d829a64ef1b431f7ac76dd258c1e.tar.bz2 |
Issue #13012: Allow 'keepends' to be passed as a keyword argument in str.splitlines, bytes.splitlines and bytearray.splitlines.
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r-- | Lib/test/string_tests.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index d792529..049929c 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -47,11 +47,12 @@ class BaseTest(unittest.TestCase): return obj # check that obj.method(*args) returns result - def checkequal(self, result, obj, methodname, *args): + def checkequal(self, result, obj, methodname, *args, **kwargs): result = self.fixtype(result) obj = self.fixtype(obj) args = self.fixtype(args) - realresult = getattr(obj, methodname)(*args) + kwargs = self.fixtype(kwargs) + realresult = getattr(obj, methodname)(*args, **kwargs) self.assertEqual( result, realresult @@ -908,7 +909,14 @@ class MixinStrUnicodeUserStringTest: self.checkequal(['abc', 'def', 'ghi'], "abc\ndef\r\nghi\n", 'splitlines') self.checkequal(['abc', 'def', 'ghi', ''], "abc\ndef\r\nghi\n\r", 'splitlines') self.checkequal(['', 'abc', 'def', 'ghi', ''], "\nabc\ndef\r\nghi\n\r", 'splitlines') - self.checkequal(['\n', 'abc\n', 'def\r\n', 'ghi\n', '\r'], "\nabc\ndef\r\nghi\n\r", 'splitlines', 1) + self.checkequal(['', 'abc', 'def', 'ghi', ''], + "\nabc\ndef\r\nghi\n\r", 'splitlines', False) + self.checkequal(['\n', 'abc\n', 'def\r\n', 'ghi\n', '\r'], + "\nabc\ndef\r\nghi\n\r", 'splitlines', True) + self.checkequal(['', 'abc', 'def', 'ghi', ''], "\nabc\ndef\r\nghi\n\r", + 'splitlines', keepends=False) + self.checkequal(['\n', 'abc\n', 'def\r\n', 'ghi\n', '\r'], + "\nabc\ndef\r\nghi\n\r", 'splitlines', keepends=True) self.checkraises(TypeError, 'abc', 'splitlines', 42, 42) |