[pypy-svn] r73440 - pypy/branch/cpython-extension/pypy/module/cpyext/test
fijal at codespeak.net
fijal at codespeak.net
Tue Apr 6 05:28:38 CEST 2010
Author: fijal
Date: Tue Apr 6 05:28:36 2010
New Revision: 73440
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_getargs.py
Log:
Improve the test. It's copied from cpython so should work, but since I already
wrote it we don't loose anything by having it.
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_getargs.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_getargs.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_getargs.py Tue Apr 6 05:28:36 2010
@@ -39,6 +39,18 @@
}
Py_INCREF(obj);
return obj;
+ '''),
+ ('twoopt', 'METH_VARARGS',
+ '''
+ PyObject *a;
+ PyObject *b = NULL;
+ if (!PyArg_ParseTuple(args, "O|O", &a, &b)) {
+ return NULL;
+ }
+ if (!b) {
+ b = PyInt_FromLong(42);
+ }
+ return b;
''')])
assert mod.oneargint(1) == 1
raises(TypeError, mod.oneargint, None)
@@ -49,3 +61,6 @@
res = mod.oneargobject(sentinel)
raises(TypeError, "mod.oneargobjectandlisttype(sentinel)")
assert res is sentinel
+ assert mod.twoopt(1) == 42
+ assert mod.twoopt(1, 2) == 2
+ raises(TypeError, mod.twoopt, 1, 2, 3)
More information about the Pypy-commit
mailing list