[pypy-svn] r48790 - in pypy/branch/ropes-unicode/pypy/objspace/std: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Mon Nov 19 15:28:34 CET 2007
Author: cfbolz
Date: Mon Nov 19 15:28:31 2007
New Revision: 48790
Modified:
pypy/branch/ropes-unicode/pypy/objspace/std/ropeunicodeobject.py
pypy/branch/ropes-unicode/pypy/objspace/std/test/test_unicodeobject.py
Log:
bug in partition
Modified: pypy/branch/ropes-unicode/pypy/objspace/std/ropeunicodeobject.py
==============================================================================
--- pypy/branch/ropes-unicode/pypy/objspace/std/ropeunicodeobject.py (original)
+++ pypy/branch/ropes-unicode/pypy/objspace/std/ropeunicodeobject.py Mon Nov 19 15:28:31 2007
@@ -724,12 +724,12 @@
space.wrap("empty separator"))
pos = rope.find(self, sub)
if pos == -1:
- return space.newtuple([w_self, W_RopeUnicodeObject.EMPTY,
+ return space.newtuple([w_unistr, W_RopeUnicodeObject.EMPTY,
W_RopeUnicodeObject.EMPTY])
else:
return space.newtuple(
[W_RopeUnicodeObject(rope.getslice_one(self, 0, pos)),
- w_sub,
+ w_unisub,
W_RopeUnicodeObject(rope.getslice_one(self, pos + sub.length(),
self.length()))])
Modified: pypy/branch/ropes-unicode/pypy/objspace/std/test/test_unicodeobject.py
==============================================================================
--- pypy/branch/ropes-unicode/pypy/objspace/std/test/test_unicodeobject.py (original)
+++ pypy/branch/ropes-unicode/pypy/objspace/std/test/test_unicodeobject.py Mon Nov 19 15:28:31 2007
@@ -472,3 +472,34 @@
"u'\\U00090418\\u027d\\U000582b9\\u54c3\\U000fcb6e'")
assert (repr(u'\n') ==
"u'\\n'")
+
+
+ def test_partition(self):
+
+ assert (u'this is the par', u'ti', u'tion method') == \
+ u'this is the partition method'.partition(u'ti')
+
+ # from raymond's original specification
+ S = u'http://www.python.org'
+ assert (u'http', u'://', u'www.python.org') == S.partition(u'://')
+ assert (u'http://www.python.org', u'', u'') == S.partition(u'?')
+ assert (u'', u'http://', u'www.python.org') == S.partition(u'http://')
+ assert (u'http://www.python.', u'org', u'') == S.partition(u'org')
+
+ raises(ValueError, S.partition, u'')
+ raises(TypeError, S.partition, None)
+
+ def test_rpartition(self):
+
+ assert ('this is the rparti', 'ti', 'on method') == \
+ 'this is the rpartition method'.rpartition('ti')
+
+ # from raymond's original specification
+ S = 'http://www.python.org'
+ assert ('http', '://', 'www.python.org') == S.rpartition('://')
+ assert ('', '', 'http://www.python.org') == S.rpartition('?')
+ assert ('', 'http://', 'www.python.org') == S.rpartition('http://')
+ assert ('http://www.python.', 'org', '') == S.rpartition('org')
+
+ raises(ValueError, S.rpartition, '')
+ raises(TypeError, S.rpartition, None)
More information about the Pypy-commit
mailing list