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 | |
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')
-rw-r--r-- | Lib/test/buffer_tests.py | 8 | ||||
-rw-r--r-- | Lib/test/string_tests.py | 14 | ||||
-rwxr-xr-x | Lib/test/test_userstring.py | 4 |
3 files changed, 20 insertions, 6 deletions
diff --git a/Lib/test/buffer_tests.py b/Lib/test/buffer_tests.py index 6d20f7d..cf54c28 100644 --- a/Lib/test/buffer_tests.py +++ b/Lib/test/buffer_tests.py @@ -200,7 +200,13 @@ class MixinBytesBufferCommonTests(object): self.marshal(b'abc\ndef\r\nghi\n\r').splitlines()) self.assertEqual([b'', b'abc', b'def', b'ghi', b''], self.marshal(b'\nabc\ndef\r\nghi\n\r').splitlines()) + self.assertEqual([b'', b'abc', b'def', b'ghi', b''], + self.marshal(b'\nabc\ndef\r\nghi\n\r').splitlines(False)) + self.assertEqual([b'\n', b'abc\n', b'def\r\n', b'ghi\n', b'\r'], + self.marshal(b'\nabc\ndef\r\nghi\n\r').splitlines(True)) + self.assertEqual([b'', b'abc', b'def', b'ghi', b''], + self.marshal(b'\nabc\ndef\r\nghi\n\r').splitlines(keepends=False)) self.assertEqual([b'\n', b'abc\n', b'def\r\n', b'ghi\n', b'\r'], - self.marshal(b'\nabc\ndef\r\nghi\n\r').splitlines(1)) + self.marshal(b'\nabc\ndef\r\nghi\n\r').splitlines(keepends=True)) self.assertRaises(TypeError, self.marshal(b'abc').splitlines, 42, 42) 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) diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py index 7a8b932..d5d0c89 100755 --- a/Lib/test/test_userstring.py +++ b/Lib/test/test_userstring.py @@ -17,11 +17,11 @@ class UserStringTest( # Overwrite the three testing methods, because UserString # can't cope with arguments propagated to UserString # (and we don't test with subclasses) - def checkequal(self, result, object, methodname, *args): + def checkequal(self, result, object, methodname, *args, **kwargs): result = self.fixtype(result) object = self.fixtype(object) # we don't fix the arguments, because UserString can't cope with it - realresult = getattr(object, methodname)(*args) + realresult = getattr(object, methodname)(*args, **kwargs) self.assertEqual( result, realresult |