Author: mattip <matti.pi...@gmail.com> Branch: cpyext-for-merge Changeset: r83965:cfc882e1b8c2 Date: 2016-04-27 09:18 +0300 http://bitbucket.org/pypy/pypy/changeset/cfc882e1b8c2/
Log: fix or skip runappdirect variations of tests diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py --- a/pypy/module/cpyext/pyobject.py +++ b/pypy/module/cpyext/pyobject.py @@ -220,11 +220,6 @@ assert isinstance(w_type, W_TypeObject) return get_typedescr(w_type.layout.typedef).realize(space, ref) - -def debug_collect(): - rawrefcount._collect() - - def as_pyobj(space, w_obj): """ Returns a 'PyObject *' representing the given intepreter object. diff --git a/pypy/module/cpyext/test/foo.c b/pypy/module/cpyext/test/foo.c --- a/pypy/module/cpyext/test/foo.c +++ b/pypy/module/cpyext/test/foo.c @@ -210,7 +210,7 @@ 0, /*tp_getattro*/ (setattrofunc)foo_setattro, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ foo_doc, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -2,22 +2,21 @@ import weakref import os -import py +import py, pytest from pypy.conftest import pypydir -from pypy.interpreter.error import OperationError from pypy.interpreter import gateway -from rpython.rtyper.lltypesystem import rffi, lltype, ll2ctypes +from rpython.rtyper.lltypesystem import lltype, ll2ctypes from rpython.translator.tool.cbuild import ExternalCompilationInfo from rpython.translator import platform from rpython.translator.gensupp import uniquemodulename from rpython.tool.udir import udir from pypy.module.cpyext import api from pypy.module.cpyext.state import State -from pypy.module.cpyext.pyobject import debug_collect -from pypy.module.cpyext.pyobject import Py_DecRef, InvalidPointerException +from pypy.module.cpyext.pyobject import Py_DecRef from rpython.tool.identity_dict import identity_dict from rpython.tool import leakfinder +from rpython.rlib import rawrefcount def setup_module(module): if os.name == 'nt': @@ -164,7 +163,7 @@ state.reset_borrowed_references() def check_and_print_leaks(self): - debug_collect() + rawrefcount._collect() # check for sane refcnts import gc @@ -218,7 +217,10 @@ class AppTestApi(LeakCheckingTest): def setup_class(cls): from rpython.rlib.clibffi import get_libc_name - cls.w_libc = cls.space.wrap(get_libc_name()) + if cls.runappdirect: + cls.libc = get_libc_name() + else: + cls.w_libc = cls.space.wrap(get_libc_name()) def setup_method(self, meth): freeze_refcnts(self) @@ -233,9 +235,11 @@ "the test actually passed in the first place; if it failed " "it is likely to reach this place.") + @pytest.mark.skipif('__pypy__' not in sys.builtin_module_names, reason='pypy only test') def test_only_import(self): import cpyext + @pytest.mark.skipif('__pypy__' not in sys.builtin_module_names, reason='pypy only test') def test_load_error(self): import cpyext raises(ImportError, cpyext.load_module, "missing.file", "foo") @@ -347,7 +351,11 @@ @gateway.unwrap_spec(mod=str, name=str) def reimport_module(space, mod, name): - api.load_extension_module(space, mod, name) + if self.runappdirect: + import imp + return imp.load_dynamic(name, mod) + else: + api.load_extension_module(space, mod, name) return space.getitem( space.sys.get('modules'), space.wrap(name)) @@ -394,6 +402,9 @@ """ self.imported_module_names.append(name) + def debug_collect(space): + rawrefcount._collect() + # A list of modules which the test caused to be imported (in # self.space). These will be cleaned up automatically in teardown. self.imported_module_names = [] @@ -585,6 +596,8 @@ If `cherry.date` is an extension module which imports `apple.banana`, the latter is added to `sys.modules` for the `"apple.banana"` key. """ + if self.runappdirect: + skip('record_imported_module not supported in runappdirect mode') # Build the extensions. banana = self.compile_module( "apple.banana", separate_module_files=[self.here + 'banana.c']) @@ -778,7 +791,8 @@ def test_internal_exceptions(self): - import sys + if self.runappdirect: + skip('cannot import module with undefined functions') init = """ if (Py_IsInitialized()) Py_InitModule("foo", methods); @@ -846,6 +860,7 @@ ]) raises(SystemError, mod.newexc, "name", Exception, {}) + @pytest.mark.skipif('__pypy__' not in sys.builtin_module_names, reason='pypy specific test') def test_hash_pointer(self): mod = self.import_extension('foo', [ ('get_hash', 'METH_NOARGS', @@ -896,6 +911,7 @@ print p assert 'py' in p + @pytest.mark.skipif('__pypy__' not in sys.builtin_module_names, reason='pypy only test') def test_get_version(self): mod = self.import_extension('foo', [ ('get_version', 'METH_NOARGS', diff --git a/pypy/module/cpyext/test/test_object.py b/pypy/module/cpyext/test/test_object.py --- a/pypy/module/cpyext/test/test_object.py +++ b/pypy/module/cpyext/test/test_object.py @@ -215,7 +215,11 @@ class AppTestObject(AppTestCpythonExtensionBase): def setup_class(cls): AppTestCpythonExtensionBase.setup_class.im_func(cls) - cls.w_tmpname = cls.space.wrap(str(py.test.ensuretemp("out", dir=0))) + tmpname = str(py.test.ensuretemp('out', dir=0)) + if cls.runappdirect: + cls.tmpname = tmpname + else: + cls.w_tmpname = cls.space.wrap(tmpname) def test_object_malloc(self): module = self.import_extension('foo', [ _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit