Mercurial > cpython-lru_cache-weakref
view Lib/test/test_string.py @ 22360:c8a6ea00a9e1 legacy-trunk
restructure a bit to not rely on test case execution ordering
add test case for bug #482460
| author | Skip Montanaro <skip@pobox.com> |
|---|---|
| date | Sun, 17 Mar 2002 23:03:42 +0000 |
| parents | bb566f525f12 |
| children | 7121d7d572d0 |
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 f = name 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
