summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@googlemail.com>2017-03-02 18:29:23 +0100
committerTodd Gamblin <tgamblin@llnl.gov>2017-03-02 09:29:23 -0800
commit5ce926d2d16d7ecd5aae72f586caba74cf07862d (patch)
tree6f067e564d4cffed1745fe13f6562e7f71cce38a /lib
parent88f97c07dea843f2a2c1d87347edccb69c093903 (diff)
downloadspack-5ce926d2d16d7ecd5aae72f586caba74cf07862d.tar.gz
spack-5ce926d2d16d7ecd5aae72f586caba74cf07862d.tar.bz2
spack-5ce926d2d16d7ecd5aae72f586caba74cf07862d.tar.xz
spack-5ce926d2d16d7ecd5aae72f586caba74cf07862d.zip
test/packages: fixed test suite (#3236)
It seems the tests in `packages.py` were running just because we had a specific order of execution. This should fix the problem, and make the test_suite more resilient to running order.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/packages.py205
1 files changed, 99 insertions, 106 deletions
diff --git a/lib/spack/spack/test/packages.py b/lib/spack/spack/test/packages.py
index bc1f438e44..8ae2effc38 100644
--- a/lib/spack/spack/test/packages.py
+++ b/lib/spack/spack/test/packages.py
@@ -23,115 +23,108 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import spack
+import pytest
+
from llnl.util.filesystem import join_path
from spack.repository import Repo
from spack.util.naming import mod_to_class
from spack.spec import *
-def test_load_package(builtin_mock):
- spack.repo.get('mpich')
-
-
-def test_package_name(builtin_mock):
- pkg = spack.repo.get('mpich')
- assert pkg.name == 'mpich'
-
-
-def test_package_filename(builtin_mock):
- repo = Repo(spack.mock_packages_path)
- filename = repo.filename_for_package_name('mpich')
- assert filename == join_path(
- spack.mock_packages_path,
- 'packages',
- 'mpich',
- 'package.py'
- )
-
-
-def test_nonexisting_package_filename():
- repo = Repo(spack.mock_packages_path)
- filename = repo.filename_for_package_name('some-nonexisting-package')
- assert filename == join_path(
- spack.mock_packages_path,
- 'packages',
- 'some-nonexisting-package',
- 'package.py'
- )
-
-
-def test_package_class_names():
- assert 'Mpich' == mod_to_class('mpich')
- assert 'PmgrCollective' == mod_to_class('pmgr_collective')
- assert 'PmgrCollective' == mod_to_class('pmgr-collective')
- assert 'Pmgrcollective' == mod_to_class('PmgrCollective')
- assert '_3db' == mod_to_class('3db')
-
-
-# Below tests target direct imports of spack packages from the
-# spack.pkg namespace
-def test_import_package(builtin_mock):
- import spack.pkg.builtin.mock.mpich # noqa
-
-
-def test_import_package_as(builtin_mock):
- import spack.pkg.builtin.mock.mpich as mp # noqa
-
- import spack.pkg.builtin.mock # noqa
- import spack.pkg.builtin.mock as m # noqa
- from spack.pkg.builtin import mock # noqa
-
-
-def test_inheritance_of_diretives():
- p = spack.repo.get('simple-inheritance')
-
- # Check dictionaries that should have been filled by directives
- assert len(p.dependencies) == 3
- assert 'cmake' in p.dependencies
- assert 'openblas' in p.dependencies
- assert 'mpi' in p.dependencies
- assert len(p.provided) == 2
-
- # Check that Spec instantiation behaves as we expect
- s = Spec('simple-inheritance')
- s.concretize()
- assert '^cmake' in s
- assert '^openblas' in s
- assert '+openblas' in s
- assert 'mpi' in s
-
- s = Spec('simple-inheritance~openblas')
- s.concretize()
- assert '^cmake' in s
- assert '^openblas' not in s
- assert '~openblas' in s
- assert 'mpi' in s
-
-
-def test_dependency_extensions():
- s = Spec('extension2')
- s.concretize()
- deps = set(x.name for x in s.package.dependency_activations())
- assert deps == set(['extension1'])
-
-
-def test_import_class_from_package(builtin_mock):
- from spack.pkg.builtin.mock.mpich import Mpich # noqa
-
-
-def test_import_module_from_package(builtin_mock):
- from spack.pkg.builtin.mock import mpich # noqa
-
-
-def test_import_namespace_container_modules(builtin_mock):
- import spack.pkg # noqa
- import spack.pkg as p # noqa
- from spack import pkg # noqa
-
- import spack.pkg.builtin # noqa
- import spack.pkg.builtin as b # noqa
- from spack.pkg import builtin # noqa
-
- import spack.pkg.builtin.mock # noqa
- import spack.pkg.builtin.mock as m # noqa
- from spack.pkg.builtin import mock # noqa
+@pytest.mark.usefixtures('config', 'builtin_mock')
+class TestPackage(object):
+ def test_load_package(self):
+ spack.repo.get('mpich')
+
+ def test_package_name(self):
+ pkg = spack.repo.get('mpich')
+ assert pkg.name == 'mpich'
+
+ def test_package_filename(self):
+ repo = Repo(spack.mock_packages_path)
+ filename = repo.filename_for_package_name('mpich')
+ assert filename == join_path(
+ spack.mock_packages_path,
+ 'packages',
+ 'mpich',
+ 'package.py'
+ )
+
+ def test_nonexisting_package_filename(self):
+ repo = Repo(spack.mock_packages_path)
+ filename = repo.filename_for_package_name('some-nonexisting-package')
+ assert filename == join_path(
+ spack.mock_packages_path,
+ 'packages',
+ 'some-nonexisting-package',
+ 'package.py'
+ )
+
+ def test_package_class_names(self):
+ assert 'Mpich' == mod_to_class('mpich')
+ assert 'PmgrCollective' == mod_to_class('pmgr_collective')
+ assert 'PmgrCollective' == mod_to_class('pmgr-collective')
+ assert 'Pmgrcollective' == mod_to_class('PmgrCollective')
+ assert '_3db' == mod_to_class('3db')
+
+ # Below tests target direct imports of spack packages from the
+ # spack.pkg namespace
+ def test_import_package(self):
+ import spack.pkg.builtin.mock.mpich # noqa
+
+ def test_import_package_as(self):
+ import spack.pkg.builtin.mock.mpich as mp # noqa
+
+ import spack.pkg.builtin.mock # noqa
+ import spack.pkg.builtin.mock as m # noqa
+ from spack.pkg.builtin import mock # noqa
+
+ def test_inheritance_of_diretives(self):
+ p = spack.repo.get('simple-inheritance')
+
+ # Check dictionaries that should have been filled by directives
+ assert len(p.dependencies) == 3
+ assert 'cmake' in p.dependencies
+ assert 'openblas' in p.dependencies
+ assert 'mpi' in p.dependencies
+ assert len(p.provided) == 2
+
+ # Check that Spec instantiation behaves as we expect
+ s = Spec('simple-inheritance')
+ s.concretize()
+ assert '^cmake' in s
+ assert '^openblas' in s
+ assert '+openblas' in s
+ assert 'mpi' in s
+
+ s = Spec('simple-inheritance~openblas')
+ s.concretize()
+ assert '^cmake' in s
+ assert '^openblas' not in s
+ assert '~openblas' in s
+ assert 'mpi' in s
+
+ def test_dependency_extensions(self):
+ s = Spec('extension2')
+ s.concretize()
+ deps = set(x.name for x in s.package.dependency_activations())
+ assert deps == set(['extension1'])
+
+ def test_import_class_from_package(self):
+ from spack.pkg.builtin.mock.mpich import Mpich # noqa
+
+ def test_import_module_from_package(self):
+ from spack.pkg.builtin.mock import mpich # noqa
+
+ def test_import_namespace_container_modules(self):
+ import spack.pkg # noqa
+ import spack.pkg as p # noqa
+ from spack import pkg # noqa
+
+ import spack.pkg.builtin # noqa
+ import spack.pkg.builtin as b # noqa
+ from spack.pkg import builtin # noqa
+
+ import spack.pkg.builtin.mock # noqa
+ import spack.pkg.builtin.mock as m # noqa
+ from spack.pkg.builtin import mock # noqa