[Python-checkins] python/dist/src/Lib/test test_unicode.py,1.55,1.56 test_string.py,1.15,1.16
doerwalter@sourceforge.net
doerwalter@sourceforge.net
Wed, 17 Apr 2002 14:34:07 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv16177/Lib/test
Modified Files:
test_unicode.py test_string.py
Log Message:
Apply diff3.txt from SF patch http://www.python.org/sf/536241
If a str or unicode method returns the original object,
make sure that for str and unicode subclasses the original
will not be returned.
This should prevent SF bug http://www.python.org/sf/460020
from reappearing.
Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** test_unicode.py 16 Apr 2002 01:38:40 -0000 1.55
--- test_unicode.py 17 Apr 2002 21:34:05 -0000 1.56
***************
*** 53,56 ****
--- 53,75 ----
else:
exc = None
+ if value == output and type(value) is type(output):
+ # if the original is returned make sure that
+ # this doesn't happen with subclasses
+ if value is input:
+ class usub(unicode):
+ def __repr__(self):
+ return 'usub(%r)' % unicode.__repr__(self)
+ input = usub(input)
+ try:
+ f = getattr(input, method)
+ value = apply(f, args)
+ except:
+ value = sys.exc_type
+ exc = sys.exc_info()[:2]
+ if value is input:
+ if verbose:
+ print 'no'
+ print '*',f, `input`, `output`, `value`
+ return
if value != output or type(value) is not type(output):
if verbose:
***************
*** 64,67 ****
--- 83,87 ----
test('capitalize', u' hello ', u' hello ')
+ test('capitalize', u'Hello ', u'Hello ')
test('capitalize', u'hello ', u'Hello ')
test('capitalize', u'aaaa', u'Aaaa')
***************
*** 76,79 ****
--- 96,100 ----
test('title', u' hello ', u' Hello ')
+ test('title', u'Hello ', u'Hello ')
test('title', u'hello ', u'Hello ')
test('title', u"fOrMaT thIs aS titLe String", u'Format This As Title String')
***************
*** 201,204 ****
--- 222,226 ----
test('expandtabs', u'abc\rab\tdef\ng\thi', u'abc\rab def\ng hi', 4)
test('expandtabs', u'abc\r\nab\tdef\ng\thi', u'abc\r\nab def\ng hi', 4)
+ test('expandtabs', u'abc\r\nab\r\ndef\ng\r\nhi', u'abc\r\nab\r\ndef\ng\r\nhi', 4)
if 0:
Index: test_string.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_string.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** test_string.py 9 Dec 2001 16:06:29 -0000 1.15
--- test_string.py 17 Apr 2002 21:34:05 -0000 1.16
***************
*** 23,26 ****
--- 23,45 ----
value = sys.exc_type
f = name
+ if value == output:
+ # if the original is returned make sure that
+ # this doesn't happen with subclasses
+ if value is input:
+ class ssub(str):
+ def __repr__(self):
+ return 'ssub(%r)' % str.__repr__(self)
+ input = ssub(input)
+ try:
+ f = getattr(input, name)
+ value = apply(f, args)
+ except AttributeError:
+ f = getattr(string, name)
+ value = apply(f, (input,) + args)
+ if value is input:
+ if verbose:
+ print 'no'
+ print '*',f, `input`, `output`, `value`
+ return
if value != output:
if verbose: