Author: Matti Picus <matti.pi...@gmail.com> Branch: cpyext-int Changeset: r67906:dd36dcfccc8d Date: 2013-11-09 18:43 +0200 http://bitbucket.org/pypy/pypy/changeset/dd36dcfccc8d/
Log: move test diff --git a/pypy/module/cpyext/test/test_intobject.py b/pypy/module/cpyext/test/test_intobject.py --- a/pypy/module/cpyext/test/test_intobject.py +++ b/pypy/module/cpyext/test/test_intobject.py @@ -97,7 +97,7 @@ return (PyObject *)enumObj; """), - ], + ], prologue=""" typedef struct { @@ -166,3 +166,24 @@ assert isinstance(a, int) assert a == int(a) == 42 assert a.name == "ULTIMATE_ANSWER" + + def test_int_cast(self): + mod = self.import_extension('foo', [ + #prove it works for ints + ("test_int", "METH_NOARGS", + """ + PyObject * obj = PyInt_FromLong(42); + if (!PyInt_Check(obj)) { + Py_DECREF(obj); + PyErr_SetNone(PyExc_ValueError); + return NULL; + } + PyObject * val = PyInt_FromLong(((PyIntObject *)obj)->ob_ival); + Py_DECREF(obj); + return val; + """ + ), + ], prologue='#include <numpy/arrayobject.h>') + i = mod.test_int() + assert isinstance(i, int) + assert i == 42 diff --git a/pypy/module/cpyext/test/test_ndarrayobject.py b/pypy/module/cpyext/test/test_ndarrayobject.py --- a/pypy/module/cpyext/test/test_ndarrayobject.py +++ b/pypy/module/cpyext/test/test_ndarrayobject.py @@ -1,5 +1,3 @@ -import py - from pypy.module.cpyext.test.test_api import BaseApiTest from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase from rpython.rtyper.lltypesystem import rffi, lltype @@ -287,23 +285,4 @@ dt = mod.test_DescrFromType(11) assert dt.num == 11 - def test_int_cast(self): - mod = self.import_extension('foo', [ - #prove it works for ints - ("test_int", "METH_NOARGS", - """ - PyObject * obj = PyInt_FromLong(42); - if (!PyInt_Check(obj)) { - Py_DECREF(obj); - PyErr_SetNone(PyExc_ValueError); - return NULL; - } - PyObject * val = PyInt_FromLong(((PyIntObject *)obj)->ob_ival); - Py_DECREF(obj); - return val; - """ - ), - ], prologue='#include <numpy/arrayobject.h>') - i = mod.test_int() - assert isinstance(i, int) - assert i == 42 + _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit