summaryrefslogtreecommitdiff
path: root/Lib/test/test_extcall.py
diff options
context:
space:
mode:
authorKa-Ping Yee <ping@zesty.ca>2001-01-15 22:14:16 +0000
committerKa-Ping Yee <ping@zesty.ca>2001-01-15 22:14:16 +0000
commit2057970601b99863c06be1b266247a0fab35bd9b (patch)
tree74e1565eca3f15bb04d350d566535027503cf82d /Lib/test/test_extcall.py
parent1ff08b1243dcb07db975640b2f3cbc82985bee81 (diff)
downloadcpython-git-2057970601b99863c06be1b266247a0fab35bd9b.tar.gz
This patch makes sure that the function name always appears in the error
message, and tries to make the messages more consistent and helpful when the wrong number of arguments or duplicate keyword arguments are supplied. Comes with more tests for test_extcall.py and and an update to an error message in test/output/test_pyexpat.
Diffstat (limited to 'Lib/test/test_extcall.py')
-rw-r--r--Lib/test/test_extcall.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py
index cc42818c9a..b53ced7503 100644
--- a/Lib/test/test_extcall.py
+++ b/Lib/test/test_extcall.py
@@ -1,5 +1,6 @@
from UserList import UserList
from test_support import TestFailed
+import string
def f(*a, **k):
print a, k
@@ -172,3 +173,32 @@ except TypeError:
pass
else:
raise TestFailed, 'expected TypeError; no exception raised'
+
+a, b, d, e, v, k = 'A', 'B', 'D', 'E', 'V', 'K'
+funcs = []
+maxargs = {}
+for args in ['', 'a', 'ab']:
+ for defargs in ['', 'd', 'de']:
+ for vararg in ['', 'v']:
+ for kwarg in ['', 'k']:
+ name = 'z' + args + defargs + vararg + kwarg
+ arglist = list(args) + map(
+ lambda x: '%s="%s"' % (x, x), defargs)
+ if vararg: arglist.append('*' + vararg)
+ if kwarg: arglist.append('**' + kwarg)
+ decl = 'def %s(%s): print "ok %s", a, b, d, e, v, k' % (
+ name, string.join(arglist, ', '), name)
+ exec(decl)
+ func = eval(name)
+ funcs.append(func)
+ maxargs[func] = len(args + defargs)
+
+for name in ['za', 'zade', 'zabk', 'zabdv', 'zabdevk']:
+ func = eval(name)
+ for args in [(), (1, 2), (1, 2, 3, 4, 5)]:
+ for kwargs in ['', 'a', 'd', 'ad', 'abde']:
+ kwdict = {}
+ for k in kwargs: kwdict[k] = k + k
+ print func.func_name, args, kwdict, '->',
+ try: apply(func, args, kwdict)
+ except TypeError, err: print err