Mercurial > cpython-lru_cache-weakref
view Lib/test/test_userstring.py @ 25135:0f0016632be4 legacy-trunk
_formatparam(), set_param(): RFC 2231 encoding support by Oleg
Broytmann in SF patch #600096. Specifically, the former function now
encodes the triplets, while the latter adds optional charset and
language arguments.
| author | Barry Warsaw <barry@python.org> |
|---|---|
| date | Fri, 06 Sep 2002 03:55:04 +0000 |
| parents | 274e42a691e0 |
| children | fe10ece8ba68 |
line wrap: on
line source
#!/usr/bin/env python import sys from test.test_support import verbose from test import string_tests # UserString is a wrapper around the native builtin string type. # UserString instances should behave similar to builtin string objects. # The test cases were in part derived from 'test_string.py'. from UserString import UserString if __name__ == "__main__": verbose = '-v' in sys.argv tested_methods = {} def test(methodname, input, output, *args): global tested_methods tested_methods[methodname] = 1 if verbose: print '%r.%s(%s)' % (input, methodname, ", ".join(map(repr, args))), u = UserString(input) objects = [input, u, UserString(u)] res = [""] * 3 for i in range(3): object = objects[i] try: f = getattr(object, methodname) except AttributeError: f = None res[i] = AttributeError else: try: res[i] = apply(f, args) except: res[i] = sys.exc_type if res[0] == res[1] == res[2] == output: if verbose: print 'yes' else: if verbose: print 'no' print (methodname, input, output, args, res[0], res[1], res[2]) string_tests.run_method_tests(test) string_tests.run_contains_tests(test) string_tests.run_inplace_tests(UserString)
