diff options
| author | Armin Rigo <arigo@tunes.org> | 2016-01-08 08:17:36 +0100 |
|---|---|---|
| committer | Armin Rigo <arigo@tunes.org> | 2016-01-08 08:17:36 +0100 |
| commit | 7fdcd73c2603b78dcc34c81251a4cc187e23ed4d (patch) | |
| tree | 13f4f923a07389c5be944800e75b0705e37b4b88 /testing/embedding/test_basic.py | |
| parent | 08ed5b405be38cbe5ee650a9a0dd527f02effb64 (diff) | |
| download | cffi-7fdcd73c2603b78dcc34c81251a4cc187e23ed4d.tar.gz | |
Py3 fixes. Skip the embedding tests if linking with -lpython%d.%d
fails (likely, the Python was not compiled with --enable-shared)
Diffstat (limited to 'testing/embedding/test_basic.py')
| -rw-r--r-- | testing/embedding/test_basic.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/testing/embedding/test_basic.py b/testing/embedding/test_basic.py index d255f1e..52d73c4 100644 --- a/testing/embedding/test_basic.py +++ b/testing/embedding/test_basic.py @@ -2,14 +2,33 @@ import py import sys, os, re import shutil, subprocess, time from testing.udir import udir +import cffi local_dir = os.path.dirname(os.path.abspath(__file__)) +_link_error = '?' + +def check_lib_python_found(tmpdir): + global _link_error + if _link_error == '?': + ffi = cffi.FFI() + kwds = {} + ffi._apply_embedding_fix(kwds) + ffi.set_source("_test_lib_python_found", "", **kwds) + try: + ffi.compile(tmpdir=tmpdir) + except cffi.VerificationError as e: + _link_error = e + else: + _link_error = None + if _link_error: + py.test.skip(str(_link_error)) class EmbeddingTests: _compiled_modules = {} def setup_method(self, meth): + check_lib_python_found(str(udir.ensure('embedding', dir=1))) self._path = udir.join('embedding', meth.__name__) def get_path(self): @@ -74,7 +93,7 @@ class EmbeddingTests: else: libpath = path env['LD_LIBRARY_PATH'] = libpath - print 'running %r in %r' % (name, path) + print('running %r in %r' % (name, path)) popen = subprocess.Popen([name], cwd=path, env=env, stdout=subprocess.PIPE) result = popen.stdout.read() |
