[pypy-commit] pypy cpyext-best_base: add a passing test: getitem is returning a dtype instance that can be used as an int
mattip
noreply at buildbot.pypy.org
Thu Oct 10 17:50:27 CEST 2013
Author: Matti Picus <matti.picus at gmail.com>
Branch: cpyext-best_base
Changeset: r67300:45a97e4c2960
Date: 2013-10-10 18:50 +0300
http://bitbucket.org/pypy/pypy/changeset/45a97e4c2960/
Log: add a passing test: getitem is returning a dtype instance that can
be used as an int
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
@@ -320,6 +320,24 @@
obj = foo.new()
assert module.hack_tp_dict(obj) == 2
+ def test_getitem(self):
+ import numpypy as np
+ module = self.import_extension('foo', [
+ ("test_getitem", "METH_O",
+ '''
+ PyObject *j, *retval;
+ j = PyInt_FromLong(2);
+ retval = PyObject_GetItem(args, j);
+ Py_DECREF(j);
+ return retval;
+ '''),
+ ],
+ )
+ val = module.test_getitem([10, 11, 12, 13, 14])
+ assert val == 12
+ val = module.test_getitem(np.array([20, 21, 22, 23, 24, 25]))
+ assert val == 22
+
class TestTypes(BaseApiTest):
def test_type_attributes(self, space, api):
@@ -365,6 +383,7 @@
ref = make_ref(space, w_obj)
api.Py_DecRef(ref)
+
class AppTestSlots(AppTestCpythonExtensionBase):
def test_some_slots(self):
module = self.import_extension('foo', [
More information about the pypy-commit
mailing list