[Python-checkins] CVS: python/dist/src/Lib/test test_extcall.py,1.8,1.9

Ka-Ping Yee ping@users.sourceforge.net
Mon, 15 Jan 2001 14:14:18 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv31281/Lib/test

Modified Files:
	test_extcall.py 
Log Message:
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.


Index: test_extcall.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_extcall.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** test_extcall.py	2001/01/04 22:33:02	1.8
--- test_extcall.py	2001/01/15 22:14:16	1.9
***************
*** 1,4 ****
--- 1,5 ----
  from UserList import UserList
  from test_support import TestFailed
+ import string
  
  def f(*a, **k):
***************
*** 173,174 ****
--- 174,204 ----
  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