Files
deb-python-cassandra-driver/tests/unit/cython/utils.py
2015-08-08 12:28:53 +01:00

23 lines
642 B
Python

from cassandra.cython_deps import HAVE_CYTHON, HAVE_NUMPY
try:
import unittest2 as unittest
except ImportError:
import unittest # noqa
def cyimport(import_path):
"""
Import a Cython module if available, otherwise return None
(and skip any relevant tests).
"""
try:
return __import__(import_path, fromlist=True)
except ImportError:
if HAVE_CYTHON:
raise
return None
# @cythontest
# def test_something(self): ...
cythontest = unittest.skipUnless(HAVE_CYTHON, 'Cython is not available')
numpytest = unittest.skipUnless(HAVE_CYTHON and HAVE_NUMPY, 'NumPy is not available')