summaryrefslogtreecommitdiffstats
path: root/Lib/test/string_tests.py
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2011-09-24 08:14:39 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2011-09-24 08:14:39 (GMT)
commit0d5f6adbb3e5d829a64ef1b431f7ac76dd258c1e (patch)
treed07d766085d981b7021696af28b0ea7bf4dd8ecc /Lib/test/string_tests.py
parenta61b053e611dd97258231913b79fafe0a9a16125 (diff)
downloadcpython-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.py14
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)