summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_userstring.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_userstring.py')
-rwxr-xr-xLib/test/test_userstring.py30
1 files changed, 14 insertions, 16 deletions
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index a8df84d..86997ce 100755
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -8,15 +8,15 @@ import string_tests
from UserString import UserString
if __name__ == "__main__":
- verbose = 0
+ verbose = '-v' in sys.argv
tested_methods = {}
-def test(methodname, input, *args):
+def test(methodname, input, output, *args):
global tested_methods
tested_methods[methodname] = 1
if verbose:
- print '%s.%s(%s) ' % (input, methodname, args),
+ print '%r.%s(%s)' % (input, methodname, ", ".join(map(repr, args))),
u = UserString(input)
objects = [input, u, UserString(u)]
res = [""] * 3
@@ -24,22 +24,20 @@ def test(methodname, input, *args):
object = objects[i]
try:
f = getattr(object, methodname)
- res[i] = apply(f, args)
- except:
- res[i] = sys.exc_type
- if res[0] != res[1]:
- if verbose:
- print 'no'
- print `input`, f, `res[0]`, "<>", `res[1]`
- else:
+ 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'
- if res[1] != res[2]:
- if verbose:
- print 'no'
- print `input`, f, `res[1]`, "<>", `res[2]`
else:
if verbose:
- print 'yes'
+ print 'no'
+ print (methodname, input, output, args, res[0], res[1], res[2])
string_tests.run_method_tests(test)