Mercurial > cpython-lru_cache-weakref
view Lib/test/test_string.py @ 17322:bd110eadc19a legacy-trunk
One-liner critical fix from Jim Fulton: Eric's string-method crusade
got the order backwards in a line (for .find()).
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Thu, 05 Apr 2001 22:26:23 +0000 |
| parents | e59b835ad89a |
| children | bb566f525f12 |
line wrap: on
line source
from test_support import verbose, TestSkipped import string_tests import string, sys # XXX: kludge... short circuit if strings don't have methods try: ''.join except AttributeError: raise TestSkipped def test(name, input, output, *args): if verbose: print 'string.%s%s =? %s... ' % (name, (input,) + args, output), try: # Prefer string methods over string module functions try: f = getattr(input, name) value = apply(f, args) except AttributeError: f = getattr(string, name) value = apply(f, (input,) + args) except: value = sys.exc_type if value != output: if verbose: print 'no' print f, `input`, `output`, `value` else: if verbose: print 'yes' string_tests.run_module_tests(test) string_tests.run_method_tests(test) string.whitespace string.lowercase string.uppercase
