[pypy-commit] pypy ffi-backend: Hack at the test file until the tests run (and show bugs).
arigo
noreply at buildbot.pypy.org
Thu Jun 21 20:17:16 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: ffi-backend
Changeset: r55752:378e6c720593
Date: 2012-06-21 20:17 +0200
http://bitbucket.org/pypy/pypy/changeset/378e6c720593/
Log: Hack at the test file until the tests run (and show bugs).
diff --git a/pypy/module/_ffi_backend/ctypeobj.py b/pypy/module/_ffi_backend/ctypeobj.py
--- a/pypy/module/_ffi_backend/ctypeobj.py
+++ b/pypy/module/_ffi_backend/ctypeobj.py
@@ -91,7 +91,7 @@
value = 0
else:
value = misc.as_unsigned_long_long(space, w_ob, strict=False)
- w_cdata = cdataobj.W_CDataOwn(space, self.size, self)
+ w_cdata = cdataobj.W_CDataOwnFromCasted(space, self.size, self)
w_cdata.write_raw_integer_data(value)
return w_cdata
@@ -158,7 +158,7 @@
value = 0.0
else:
value = space.float_w(w_ob)
- w_cdata = cdataobj.W_CDataOwn(space, self.size, self)
+ w_cdata = cdataobj.W_CDataOwnFromCasted(space, self.size, self)
w_cdata.write_raw_float_data(value)
return w_cdata
diff --git a/pypy/module/_ffi_backend/test/test_c.py b/pypy/module/_ffi_backend/test/test_c.py
--- a/pypy/module/_ffi_backend/test/test_c.py
+++ b/pypy/module/_ffi_backend/test/test_c.py
@@ -1,18 +1,39 @@
from __future__ import with_statement
+"""
+This file is OBSCURE. Really. The purpose is to avoid copying and changing
+'test_c.py' from cffi/c/.
+"""
import py
from pypy.tool.udir import udir
from pypy.conftest import gettestobjspace
+from pypy.interpreter import gateway
from pypy.module._ffi_backend.test import _backend_test_c
+from pypy.module._ffi_backend import Module
class AppTestC(object):
"""Populated below, hack hack hack."""
+def find_and_load_library_for_test(space, w_name):
+ import ctypes.util
+ path = ctypes.util.find_library(space.str_w(w_name))
+ return space.appexec([space.wrap(path)], """(path):
+ import _ffi_backend
+ return _ffi_backend.load_library(path)""")
+
+
space = gettestobjspace(usemodules=('_ffi_backend',))
src = py.path.local(__file__).join('..', '_backend_test_c.py').read()
-w_namespace = space.appexec([], "():\n" +
+w_func = space.wrap(gateway.interp2app(find_and_load_library_for_test))
+all_names = ', '.join(Module.interpleveldefs.keys())
+w_namespace = space.appexec([w_func], "(func):" +
+ '\n from _ffi_backend import %s' % all_names +
+ '\n class py:' +
+ '\n class test:' +
+ '\n raises = staticmethod(raises)' +
src.replace('\n', '\n ') +
+ '\n find_and_load_library = func' +
'\n return locals()\n')
AppTestC.w_namespace = w_namespace
More information about the pypy-commit
mailing list