mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Moved inplace add and multiply methods from UserString to MutableString.
Closes SF Bug #592573 where inplace add mutated a UserString. Added unittests to verify the bug is cleared.
This commit is contained in:
parent
48923c5533
commit
c35491ee3a
4 changed files with 19 additions and 11 deletions
|
@ -314,3 +314,9 @@ def run_contains_tests(test):
|
|||
test('__contains__', 'asdf', True, 'asdf') # vereq('asdf' in 'asdf', True)
|
||||
test('__contains__', 'asd', False, 'asdf') # vereq('asdf' in 'asd', False)
|
||||
test('__contains__', '', False, 'asdf') # vereq('asdf' in '', False)
|
||||
|
||||
def run_inplace_tests(constructor):
|
||||
# Verify clearing of SF bug #592573
|
||||
s = t = constructor('abc')
|
||||
s += constructor('def')
|
||||
verify(s != t, 'in-place concatenate should create a new object')
|
||||
|
|
|
@ -52,6 +52,7 @@ def test(name, input, output, *args):
|
|||
string_tests.run_module_tests(test)
|
||||
string_tests.run_method_tests(test)
|
||||
string_tests.run_contains_tests(test)
|
||||
string_tests.run_inplace_tests(str)
|
||||
|
||||
string.whitespace
|
||||
string.lowercase
|
||||
|
|
|
@ -42,3 +42,4 @@ def test(methodname, input, output, *args):
|
|||
|
||||
string_tests.run_method_tests(test)
|
||||
string_tests.run_contains_tests(test)
|
||||
string_tests.run_inplace_tests(UserString)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue