needforspeed: partition implementation, part two.

feel free to improve the documentation and the docstrings.
This commit is contained in:
Fredrik Lundh 2006-05-26 08:54:28 +00:00
parent 19bebf2e2f
commit 06a69dd8ff
5 changed files with 143 additions and 78 deletions

View file

@ -900,6 +900,21 @@ class MixinStrUnicodeUserStringTest:
self.checkequal('A', 'a', 'title')
self.checkequal(True, 'a', 'islower')
def test_partition(self):
self.checkequal(('this', ' is ', 'the partition method'),
'this is the partition method', 'partition', ' is ')
# from raymond's original specification
S = 'http://www.python.org'
self.checkequal(('http', '://', 'www.python.org'), S, 'partition', '://')
self.checkequal(('http://www.python.org', '', ''), S, 'partition', '?')
self.checkequal(('', 'http://', 'www.python.org'), S, 'partition', 'http://')
self.checkequal(('http://www.python.', 'org', ''), S, 'partition', 'org')
self.checkraises(ValueError, S, 'partition', '')
self.checkraises(TypeError, S, 'partition', None)
class MixinStrStringUserStringTest:
# Additional tests for 8bit strings, i.e. str, UserString and