diff options
author | Fredrik Lundh <fredrik@pythonware.com> | 2006-05-26 08:54:28 (GMT) |
---|---|---|
committer | Fredrik Lundh <fredrik@pythonware.com> | 2006-05-26 08:54:28 (GMT) |
commit | 06a69dd8ffcbac16e7f5c81b457c40ca4ce94c00 (patch) | |
tree | 96534671057ec865841680a25ef0af247b012a7b /Lib | |
parent | 19bebf2e2fd6121435c3af26fbd857f1994df8bd (diff) | |
download | cpython-06a69dd8ffcbac16e7f5c81b457c40ca4ce94c00.zip cpython-06a69dd8ffcbac16e7f5c81b457c40ca4ce94c00.tar.gz cpython-06a69dd8ffcbac16e7f5c81b457c40ca4ce94c00.tar.bz2 |
needforspeed: partition implementation, part two.
feel free to improve the documentation and the docstrings.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/string_tests.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index d4fdd8f..260b2d8 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -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 |