mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-03 16:39:25 +01:00
Thought of a bug, wrote a test, discovered it was a bug, fixed it.
This commit is contained in:
parent
29d297af8d
commit
f325de3a76
@ -127,6 +127,8 @@ def all(p, seq):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def rsplit(s, sep=None, maxsplit=-1):
|
def rsplit(s, sep=None, maxsplit=-1):
|
||||||
|
if sep is not None:
|
||||||
|
sep = sep[::-1]
|
||||||
L = s[::-1].split(sep, maxsplit)
|
L = s[::-1].split(sep, maxsplit)
|
||||||
L.reverse()
|
L.reverse()
|
||||||
return [s[::-1] for s in L]
|
return [s[::-1] for s in L]
|
||||||
|
@ -94,6 +94,7 @@ class FunctionsTest(unittest.TestCase):
|
|||||||
['foo bar', 'baz'])
|
['foo bar', 'baz'])
|
||||||
self.assertEqual(rsplit('foo bar baz', maxsplit=1),
|
self.assertEqual(rsplit('foo bar baz', maxsplit=1),
|
||||||
['foo bar', 'baz'])
|
['foo bar', 'baz'])
|
||||||
|
self.assertEqual(rsplit('foobarbaz', 'bar'), ['foo', 'baz'])
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
Reference in New Issue
Block a user