Thought of a bug, wrote a test, discovered it was a bug, fixed it.

This commit is contained in:
Jeremy Fincher 2003-09-22 13:04:15 +00:00
parent 29d297af8d
commit f325de3a76
2 changed files with 3 additions and 0 deletions

View File

@ -127,6 +127,8 @@ def all(p, seq):
return True
def rsplit(s, sep=None, maxsplit=-1):
if sep is not None:
sep = sep[::-1]
L = s[::-1].split(sep, maxsplit)
L.reverse()
return [s[::-1] for s in L]

View File

@ -94,6 +94,7 @@ class FunctionsTest(unittest.TestCase):
['foo bar', 'baz'])
self.assertEqual(rsplit('foo bar baz', maxsplit=1),
['foo bar', 'baz'])
self.assertEqual(rsplit('foobarbaz', 'bar'), ['foo', 'baz'])
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: