mirror of
https://github.com/python/cpython.git
synced 2025-09-10 18:58:35 +00:00
needforspeed: partition implementation, part two.
feel free to improve the documentation and the docstrings.
This commit is contained in:
parent
19bebf2e2f
commit
06a69dd8ff
5 changed files with 143 additions and 78 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue