Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Lib/test/string_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,22 @@ def test_split(self):
self.checkraises(ValueError, 'hello', 'split', '')
self.checkraises(ValueError, 'hello', 'split', '', 0)

# without args, any whitespace is a separator
self.checkequal(['a', 'b', 'c', 'd', 'e'], 'a b\tc\nd \n e ', 'split')

# with sep=None, any whitespace is a separator
self.checkequal(['a', 'b', 'c', 'd', 'e'], 'a b\tc\nd \n e ', 'split', sep=None)

# Without an explicit `sep`, or sep=None, empty strings are pruned from result
self.checkequal([], '', 'split')
self.checkequal([], '', 'split', sep=None)

# With an explicit, non-None `sep`, empty strings are not pruned from result
self.checkequal([''], '', 'split', sep=',')

# keepempty=False to remove empty strings from result
self.checkequal([], '', 'split', sep=',', keepempty=False)

def test_rsplit(self):
# without arg
self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit')
Expand Down