PythonPackage: Let There Be Tests! (#2869)
* Run python setup.py test if --run-tests * Attempt to import the Python module after installation * Add testing support to numpy and scipy * Remove duplicated comments * Update to new run-tests callback methodology * Remove unrelated changes for another PR
This commit is contained in:

committed by
Todd Gamblin

parent
3ade829566
commit
bc404532ea
@@ -34,6 +34,10 @@ class PyNose(PythonPackage):
|
||||
list_url = "https://pypi.python.org/pypi/nose/"
|
||||
list_depth = 2
|
||||
|
||||
import_modules = [
|
||||
'nose', 'nose.ext', 'nose.plugins', 'nose.sphinx', 'nose.tools'
|
||||
]
|
||||
|
||||
version('1.3.7', '4d3ad0ff07b61373d2cefc89c5d0b20b')
|
||||
version('1.3.6', '0ca546d81ca8309080fc80cb389e7a16')
|
||||
version('1.3.4', '6ed7169887580ddc9a8e16048d38274d')
|
||||
|
@@ -36,6 +36,18 @@ class PyNumpy(PythonPackage):
|
||||
homepage = "http://www.numpy.org/"
|
||||
url = "https://pypi.io/packages/source/n/numpy/numpy-1.9.1.tar.gz"
|
||||
|
||||
install_time_test_callbacks = ['install_test', 'import_module_test']
|
||||
|
||||
import_modules = [
|
||||
'numpy', 'numpy.compat', 'numpy.core', 'numpy.distutils', 'numpy.doc',
|
||||
'numpy.f2py', 'numpy.fft', 'numpy.lib', 'numpy.linalg', 'numpy.ma',
|
||||
'numpy.matrixlib', 'numpy.polynomial', 'numpy.random', 'numpy.testing',
|
||||
'numpy.distutils.command', 'numpy.distutils.fcompiler'
|
||||
]
|
||||
|
||||
# FIXME: numpy._build_utils and numpy.core.code_generators failed to import
|
||||
# FIXME: Is this expected?
|
||||
|
||||
version('1.12.0', '33e5a84579f31829bbbba084fe0a4300',
|
||||
url="https://pypi.io/packages/source/n/numpy/numpy-1.12.0.zip")
|
||||
version('1.11.2', '03bd7927c314c43780271bf1ab795ebc')
|
||||
@@ -53,6 +65,10 @@ class PyNumpy(PythonPackage):
|
||||
depends_on('blas', when='+blas')
|
||||
depends_on('lapack', when='+lapack')
|
||||
|
||||
# Tests require:
|
||||
# TODO: Add a 'test' deptype
|
||||
# depends_on('py-nose@1.0.0:', type='test')
|
||||
|
||||
def setup_dependent_package(self, module, dependent_spec):
|
||||
python_version = self.spec['python'].version.up_to(2)
|
||||
arch = '{0}-{1}'.format(platform.system().lower(), platform.machine())
|
||||
@@ -132,3 +148,22 @@ def build_args(self, spec, prefix):
|
||||
args = ['-j', str(make_jobs)]
|
||||
|
||||
return args
|
||||
|
||||
def test(self):
|
||||
# `setup.py test` is not supported. Use one of the following
|
||||
# instead:
|
||||
#
|
||||
# - `python runtests.py` (to build and test)
|
||||
# - `python runtests.py --no-build` (to test installed numpy)
|
||||
# - `>>> numpy.test()` (run tests for installed numpy
|
||||
# from within an interpreter)
|
||||
pass
|
||||
|
||||
def install_test(self):
|
||||
# Change directories due to the following error:
|
||||
#
|
||||
# ImportError: Error importing numpy: you should not try to import
|
||||
# numpy from its source directory; please exit the numpy
|
||||
# source tree, and relaunch your python interpreter from there.
|
||||
with working_dir('..'):
|
||||
python('-c', 'import numpy; numpy.test("full", verbose=2)')
|
||||
|
@@ -33,6 +33,22 @@ class PyScipy(PythonPackage):
|
||||
homepage = "http://www.scipy.org/"
|
||||
url = "https://pypi.io/packages/source/s/scipy/scipy-0.18.1.tar.gz"
|
||||
|
||||
install_time_test_callbacks = ['install_test', 'import_module_test']
|
||||
|
||||
import_modules = [
|
||||
'scipy', 'scipy._build_utils', 'scipy._lib', 'scipy.cluster',
|
||||
'scipy.constants', 'scipy.fftpack', 'scipy.integrate',
|
||||
'scipy.interpolate', 'scipy.io', 'scipy.linalg', 'scipy.misc',
|
||||
'scipy.ndimage', 'scipy.odr', 'scipy.optimize', 'scipy.signal',
|
||||
'scipy.sparse', 'scipy.spatial', 'scipy.special', 'scipy.stats',
|
||||
'scipy.weave', 'scipy.io.arff', 'scipy.io.harwell_boeing',
|
||||
'scipy.io.matlab', 'scipy.optimize._lsq', 'scipy.sparse.csgraph',
|
||||
'scipy.sparse.linalg', 'scipy.sparse.linalg.dsolve',
|
||||
'scipy.sparse.linalg.eigen', 'scipy.sparse.linalg.isolve',
|
||||
'scipy.sparse.linalg.eigen.arpack', 'scipy.sparse.linalg.eigen.lobpcg',
|
||||
'scipy.special._precompute'
|
||||
]
|
||||
|
||||
version('0.19.0', '91b8396231eec780222a57703d3ec550',
|
||||
url="https://pypi.io/packages/source/s/scipy/scipy-0.19.0.zip")
|
||||
version('0.18.1', '5fb5fb7ccb113ab3a039702b6c2f3327')
|
||||
@@ -49,6 +65,10 @@ class PyScipy(PythonPackage):
|
||||
depends_on('blas')
|
||||
depends_on('lapack')
|
||||
|
||||
# Tests require:
|
||||
# TODO: Add a 'test' deptype
|
||||
# depends_on('py-nose', type='test')
|
||||
|
||||
def build_args(self, spec, prefix):
|
||||
args = []
|
||||
|
||||
@@ -59,3 +79,22 @@ def build_args(self, spec, prefix):
|
||||
args.extend(['-j', str(make_jobs)])
|
||||
|
||||
return args
|
||||
|
||||
def test(self):
|
||||
# `setup.py test` is not supported. Use one of the following
|
||||
# instead:
|
||||
#
|
||||
# - `python runtests.py` (to build and test)
|
||||
# - `python runtests.py --no-build` (to test installed scipy)
|
||||
# - `>>> scipy.test()` (run tests for installed scipy
|
||||
# from within an interpreter)
|
||||
pass
|
||||
|
||||
def install_test(self):
|
||||
# Change directories due to the following error:
|
||||
#
|
||||
# ImportError: Error importing scipy: you should not try to import
|
||||
# scipy from its source directory; please exit the scipy
|
||||
# source tree, and relaunch your python interpreter from there.
|
||||
with working_dir('..'):
|
||||
python('-c', 'import scipy; scipy.test("full", verbose=2)')
|
||||
|
@@ -32,6 +32,12 @@ class PySetuptools(PythonPackage):
|
||||
homepage = "https://pypi.python.org/pypi/setuptools"
|
||||
url = "https://pypi.io/packages/source/s/setuptools/setuptools-25.2.0.tar.gz"
|
||||
|
||||
import_modules = [
|
||||
'pkg_resources', 'setuptools', 'pkg_resources.extern',
|
||||
'pkg_resources._vendor', 'pkg_resources._vendor.packaging',
|
||||
'setuptools.extern', 'setuptools.command'
|
||||
]
|
||||
|
||||
version('34.2.0', '41b630da4ea6cfa5894d9eb3142922be',
|
||||
url="https://pypi.io/packages/source/s/setuptools/setuptools-34.2.0.zip")
|
||||
version('25.2.0', 'a0dbb65889c46214c691f6c516cf959c')
|
||||
@@ -53,3 +59,11 @@ class PySetuptools(PythonPackage):
|
||||
depends_on('py-packaging@16.8:', when='@34.0.0:', type=('build', 'run'))
|
||||
depends_on('py-six@1.6.0:', when='@34.0.0:', type=('build', 'run'))
|
||||
depends_on('py-appdirs@1.4.0:', when='@34.0.0:', type=('build', 'run'))
|
||||
|
||||
# Tests require:
|
||||
# TODO: Add a 'test' deptype
|
||||
# FIXME: All of these depend on setuptools, creating a dependency loop
|
||||
# FIXME: Is there any way around this problem?
|
||||
# depends_on('py-pytest-flake8', type='test')
|
||||
# depends_on('pytest@2.8:', type='test')
|
||||
# depends_on('py-mock', when='^python@:3.2', type='test')
|
||||
|
Reference in New Issue
Block a user