[pypy-commit] pypy default: Fix the original problem differently
arigo
pypy.commits at gmail.com
Fri Aug 19 02:09:40 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r86304:2430635c051f
Date: 2016-08-19 08:09 +0200
http://bitbucket.org/pypy/pypy/changeset/2430635c051f/
Log: Fix the original problem differently
diff --git a/pypy/module/_cffi_backend/test/test_re_python.py b/pypy/module/_cffi_backend/test/test_re_python.py
--- a/pypy/module/_cffi_backend/test/test_re_python.py
+++ b/pypy/module/_cffi_backend/test/test_re_python.py
@@ -69,10 +69,13 @@
sub_ffi.set_source('re_py_subsrc', None)
sub_ffi.emit_python_code(str(tmpdir.join('re_py_subsrc.py')))
#
- space.appexec([space.wrap(str(tmpdir))], """(path):
- import _cffi_backend # force it to be initialized
- import sys
- sys.path.insert(0, path)
+ cls.w_fix_path = space.appexec([space.wrap(str(tmpdir))], """(path):
+ def fix_path(ignored=None):
+ import _cffi_backend # force it to be initialized
+ import sys
+ if path not in sys.path:
+ sys.path.insert(0, path)
+ return fix_path
""")
def teardown_method(self, meth):
@@ -86,17 +89,20 @@
def test_constant_1(self):
+ self.fix_path()
from re_python_pysrc import ffi
assert ffi.integer_const('FOOBAR') == -42
assert ffi.integer_const('FOOBAZ') == -43
def test_large_constant(self):
+ self.fix_path()
from re_python_pysrc import ffi
assert ffi.integer_const('BIGPOS') == 420000000000
assert ffi.integer_const('BIGNEG') == -420000000000
def test_function(self):
import _cffi_backend
+ self.fix_path()
from re_python_pysrc import ffi
lib = ffi.dlopen(self.extmod)
assert lib.add42(-10) == 32
@@ -104,6 +110,7 @@
def test_dlclose(self):
import _cffi_backend
+ self.fix_path()
from re_python_pysrc import ffi
lib = ffi.dlopen(self.extmod)
ffi.dlclose(lib)
@@ -115,17 +122,20 @@
"library '%s' has been closed" % (self.extmod,))
def test_constant_via_lib(self):
+ self.fix_path()
from re_python_pysrc import ffi
lib = ffi.dlopen(self.extmod)
assert lib.FOOBAR == -42
assert lib.FOOBAZ == -43
def test_opaque_struct(self):
+ self.fix_path()
from re_python_pysrc import ffi
ffi.cast("struct foo_s *", 0)
raises(TypeError, ffi.new, "struct foo_s *")
def test_nonopaque_struct(self):
+ self.fix_path()
from re_python_pysrc import ffi
for p in [ffi.new("struct bar_s *", [5, b"foobar"]),
ffi.new("bar_t *", [5, b"foobar"])]:
@@ -134,12 +144,14 @@
assert p.a[5] == ord('r')
def test_enum(self):
+ self.fix_path()
from re_python_pysrc import ffi
assert ffi.integer_const("BB") == 1
e = ffi.cast("enum foo_e", 2)
assert ffi.string(e) == "CC"
def test_include_1(self):
+ self.fix_path()
from re_py_subsrc import ffi
assert ffi.integer_const('FOOBAR') == -42
assert ffi.integer_const('FOOBAZ') == -43
@@ -153,6 +165,7 @@
assert p.a[4] == ord('a')
def test_global_var(self):
+ self.fix_path()
from re_python_pysrc import ffi
lib = ffi.dlopen(self.extmod)
assert lib.globalvar42 == 1234
@@ -163,24 +176,28 @@
assert lib.globalvar42 == 1238
def test_global_const_int(self):
+ self.fix_path()
from re_python_pysrc import ffi
lib = ffi.dlopen(self.extmod)
assert lib.globalconst42 == 4321
raises(AttributeError, ffi.addressof, lib, 'globalconst42')
def test_global_const_nonint(self):
+ self.fix_path()
from re_python_pysrc import ffi
lib = ffi.dlopen(self.extmod)
assert ffi.string(lib.globalconsthello, 8) == "hello"
raises(AttributeError, ffi.addressof, lib, 'globalconsthello')
def test_rtld_constants(self):
+ self.fix_path()
from re_python_pysrc import ffi
ffi.RTLD_NOW # check that we have the attributes
ffi.RTLD_LAZY
ffi.RTLD_GLOBAL
def test_no_such_function_or_global_var(self):
+ self.fix_path()
from re_python_pysrc import ffi
lib = ffi.dlopen(self.extmod)
e = raises(ffi.error, getattr, lib, 'no_such_function')
More information about the pypy-commit
mailing list