mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
Code by Inyeol Lee, submitted to SF bug 595350, to implement
the string/unicode method .replace() with a zero-lengt first argument. Inyeol contributed tests for this too.
This commit is contained in:
parent
280488b9a3
commit
8b1a6d694f
5 changed files with 59 additions and 46 deletions
|
@ -210,12 +210,10 @@ test('replace', u'one!two!three!', u'one!two!three!', u'!', u'@', 0)
|
|||
test('replace', u'one!two!three!', u'one@two@three@', u'!', u'@')
|
||||
test('replace', u'one!two!three!', u'one!two!three!', u'x', u'@')
|
||||
test('replace', u'one!two!three!', u'one!two!three!', u'x', u'@', 2)
|
||||
try:
|
||||
u"abc".replace(u"", u"x")
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
raise TestFailed, "u.replace('', ...) should raise ValueError"
|
||||
test('replace', u'abc', u'-a-b-c-', u'', u'-')
|
||||
test('replace', u'abc', u'-a-b-c', u'', u'-', 3)
|
||||
test('replace', u'abc', u'abc', u'', u'-', 0)
|
||||
test('replace', u'', u'', u'', u'')
|
||||
|
||||
test('startswith', u'hello', True, u'he')
|
||||
test('startswith', u'hello', True, u'hello')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue