[pypy-commit] pypy py3k: Add support for keyword arguments in the test suite, add a test for the order

rguillebert noreply at buildbot.pypy.org
Sun Jan 22 11:11:46 CET 2012


Author: Romain Guillebert <romain.py at gmail.com>
Branch: py3k
Changeset: r51629:2457af5955f1
Date: 2012-01-22 11:11 +0100
http://bitbucket.org/pypy/pypy/changeset/2457af5955f1/

Log:	Add support for keyword arguments in the test suite, add a test for
	the order of kwonly arguments

diff --git a/pypy/interpreter/test/test_interpreter.py b/pypy/interpreter/test/test_interpreter.py
--- a/pypy/interpreter/test/test_interpreter.py
+++ b/pypy/interpreter/test/test_interpreter.py
@@ -4,7 +4,7 @@
 
 class TestInterpreter: 
 
-    def codetest(self, source, functionname, args):
+    def codetest(self, source, functionname, args, kwargs={}):
         """Compile and run the given code string, and then call its function
         named by 'functionname' with arguments 'args'."""
         space = self.space
@@ -22,10 +22,11 @@
         code = space.unwrap(w_code)
         code.exec_code(space, w_glob, w_glob)
 
-        wrappedargs = [w(a) for a in args]
+        wrappedargs = w(args)
+        wrappedkwargs = w(kwargs)
         wrappedfunc = space.getitem(w_glob, w(functionname))
         try:
-            w_output = space.call_function(wrappedfunc, *wrappedargs)
+            w_output = space.call(wrappedfunc, wrappedargs, wrappedkwargs)
         except error.OperationError, e:
             #e.print_detailed_traceback(space)
             return '<<<%s>>>' % e.errorstr(space)
@@ -246,6 +247,13 @@
         """
         assert self.codetest(code, "f", [1, 2]) == (1, 2, 3, 4)
 
+    def test_kwonlyargs_order(self):
+        code = """ def f(a, b, *, c, d):
+            return a, b, c, d
+        """
+        assert self.codetest(code, "f", [1, 2], {"d" : 3, "c" : 4}) == (1, 2, 3, 4)
+
+
 
 class AppTestInterpreter: 
     def test_trivial(self):


More information about the pypy-commit mailing list