Source

pypy-patches / test-kwargs.diff

# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr@gmail.com>
# Date 1291559310 -3600
# Node ID 6a8754119de51b5f687c6eabce17ce720de5ad56
# Parent  acdb39c5d553bd16830e54be061f7beeaf59463a
Test METH_KEYWORDS in the cpyext tests.

diff --git a/pypy/module/cpyext/test/test_getargs.py b/pypy/module/cpyext/test/test_getargs.py
--- a/pypy/module/cpyext/test/test_getargs.py
+++ b/pypy/module/cpyext/test/test_getargs.py
@@ -53,6 +53,16 @@ class AppTestGetargs(AppTestCpythonExten
                  b = PyInt_FromLong(42);
              /* return an owned reference */
              return b;
+             '''),
+            ('arglen', 'METH_VARARGS',
+             '''
+             Py_ssize_t r = PyTuple_Size(args);
+             return PyInt_FromSsize_t(r);
+             '''),
+            ('arglenkw', 'METH_VARARGS | METH_KEYWORDS',
+             '''
+             Py_ssize_t r = PyTuple_Size(args);
+             return PyInt_FromSsize_t(r);
              ''')])
         assert mod.oneargint(1) == 1
         raises(TypeError, mod.oneargint, None)
@@ -66,3 +76,8 @@ class AppTestGetargs(AppTestCpythonExten
         assert mod.twoopt(1) == 42
         assert mod.twoopt(1, 2) == 2
         raises(TypeError, mod.twoopt, 1, 2, 3)
+
+        assert mod.arglen('abc') == 1
+        assert mod.arglen('abc', 'def') == 2
+        assert mod.arglenkw('abc') == 1
+        assert mod.arglenkw('abc', 'def') == 2