[pypy-commit] pypy default: Add a passing test
arigo
pypy.commits at gmail.com
Tue May 10 05:19:14 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r84346:927199115c54
Date: 2016-05-10 10:21 +0200
http://bitbucket.org/pypy/pypy/changeset/927199115c54/
Log: Add a passing test
diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -1023,3 +1023,30 @@
break
self.debug_collect()
assert module.getCounter() == 7070
+
+ def test_tp_call_reverse(self):
+ module = self.import_extension('foo', [
+ ("new_obj", "METH_NOARGS",
+ '''
+ PyObject *obj;
+ Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT;
+ Foo_Type.tp_call = &my_tp_call;
+ if (PyType_Ready(&Foo_Type) < 0) return NULL;
+ obj = PyObject_New(PyObject, &Foo_Type);
+ return obj;
+ '''
+ )],
+ '''
+ static PyObject *
+ my_tp_call(PyObject *self, PyObject *args, PyObject *kwds)
+ {
+ return PyInt_FromLong(42);
+ }
+ static PyTypeObject Foo_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "foo.foo",
+ };
+ ''')
+ x = module.new_obj()
+ assert x() == 42
+ assert x(4, bar=5) == 42
More information about the pypy-commit
mailing list