summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/test/multimethod.py84
1 files changed, 47 insertions, 37 deletions
diff --git a/lib/spack/spack/test/multimethod.py b/lib/spack/spack/test/multimethod.py
index 2780c57fc5..b475b3ae93 100644
--- a/lib/spack/spack/test/multimethod.py
+++ b/lib/spack/spack/test/multimethod.py
@@ -10,69 +10,83 @@ import spack.repo
from spack.multimethod import NoSuchMethodError
-def test_no_version_match(mock_packages):
- pkg = spack.repo.get('multimethod@2.0')
+pytestmark = pytest.mark.usefixtures('mock_packages')
+
+
+@pytest.fixture(scope='module',
+ params=['multimethod', 'multimethod-inheritor'])
+def pkg_name(request):
+ """Make tests run on both multimethod and multimethod-inheritor.
+
+ This means we test all of our @when methods on a class that uses them
+ directly, AND on a class that inherits them.
+ """
+ return request.param
+
+
+def test_no_version_match(pkg_name):
+ pkg = spack.repo.get(pkg_name + '@2.0')
with pytest.raises(NoSuchMethodError):
pkg.no_version_2()
-def test_one_version_match(mock_packages):
- pkg = spack.repo.get('multimethod@1.0')
+def test_one_version_match(pkg_name):
+ pkg = spack.repo.get(pkg_name + '@1.0')
assert pkg.no_version_2() == 1
- pkg = spack.repo.get('multimethod@3.0')
+ pkg = spack.repo.get(pkg_name + '@3.0')
assert pkg.no_version_2() == 3
- pkg = spack.repo.get('multimethod@4.0')
+ pkg = spack.repo.get(pkg_name + '@4.0')
assert pkg.no_version_2() == 4
-def test_version_overlap(mock_packages):
- pkg = spack.repo.get('multimethod@2.0')
+def test_version_overlap(pkg_name):
+ pkg = spack.repo.get(pkg_name + '@2.0')
assert pkg.version_overlap() == 1
- pkg = spack.repo.get('multimethod@5.0')
+ pkg = spack.repo.get(pkg_name + '@5.0')
assert pkg.version_overlap() == 2
-def test_mpi_version(mock_packages):
- pkg = spack.repo.get('multimethod^mpich@3.0.4')
+def test_mpi_version(pkg_name):
+ pkg = spack.repo.get(pkg_name + '^mpich@3.0.4')
assert pkg.mpi_version() == 3
- pkg = spack.repo.get('multimethod^mpich2@1.2')
+ pkg = spack.repo.get(pkg_name + '^mpich2@1.2')
assert pkg.mpi_version() == 2
- pkg = spack.repo.get('multimethod^mpich@1.0')
+ pkg = spack.repo.get(pkg_name + '^mpich@1.0')
assert pkg.mpi_version() == 1
-def test_undefined_mpi_version(mock_packages):
- pkg = spack.repo.get('multimethod^mpich@0.4')
+def test_undefined_mpi_version(pkg_name):
+ pkg = spack.repo.get(pkg_name + '^mpich@0.4')
assert pkg.mpi_version() == 1
- pkg = spack.repo.get('multimethod^mpich@1.4')
+ pkg = spack.repo.get(pkg_name + '^mpich@1.4')
assert pkg.mpi_version() == 1
-def test_default_works(mock_packages):
- pkg = spack.repo.get('multimethod%gcc')
+def test_default_works(pkg_name):
+ pkg = spack.repo.get(pkg_name + '%gcc')
assert pkg.has_a_default() == 'gcc'
- pkg = spack.repo.get('multimethod%intel')
+ pkg = spack.repo.get(pkg_name + '%intel')
assert pkg.has_a_default() == 'intel'
- pkg = spack.repo.get('multimethod%pgi')
+ pkg = spack.repo.get(pkg_name + '%pgi')
assert pkg.has_a_default() == 'default'
-def test_target_match(mock_packages):
+def test_target_match(pkg_name):
platform = spack.architecture.platform()
targets = list(platform.targets.values())
for target in targets[:-1]:
- pkg = spack.repo.get('multimethod target=' + target.name)
+ pkg = spack.repo.get(pkg_name + ' target=' + target.name)
assert pkg.different_by_target() == target.name
- pkg = spack.repo.get('multimethod target=' + targets[-1].name)
+ pkg = spack.repo.get(pkg_name + ' target=' + targets[-1].name)
if len(targets) == 1:
assert pkg.different_by_target() == targets[-1].name
else:
@@ -80,34 +94,30 @@ def test_target_match(mock_packages):
pkg.different_by_target()
-def test_dependency_match(mock_packages):
- pkg = spack.repo.get('multimethod^zmpi')
+def test_dependency_match(pkg_name):
+ pkg = spack.repo.get(pkg_name + '^zmpi')
assert pkg.different_by_dep() == 'zmpi'
- pkg = spack.repo.get('multimethod^mpich')
+ pkg = spack.repo.get(pkg_name + '^mpich')
assert pkg.different_by_dep() == 'mpich'
# If we try to switch on some entirely different dep, it's ambiguous,
# but should take the first option
- pkg = spack.repo.get('multimethod^foobar')
+ pkg = spack.repo.get(pkg_name + '^foobar')
assert pkg.different_by_dep() == 'mpich'
-def test_virtual_dep_match(mock_packages):
- pkg = spack.repo.get('multimethod^mpich2')
+def test_virtual_dep_match(pkg_name):
+ pkg = spack.repo.get(pkg_name + '^mpich2')
assert pkg.different_by_virtual_dep() == 2
- pkg = spack.repo.get('multimethod^mpich@1.0')
+ pkg = spack.repo.get(pkg_name + '^mpich@1.0')
assert pkg.different_by_virtual_dep() == 1
-def test_multimethod_with_base_class(mock_packages):
- pkg = spack.repo.get('multimethod@3')
+def test_multimethod_with_base_class(pkg_name):
+ pkg = spack.repo.get(pkg_name + '@3')
assert pkg.base_method() == "subclass_method"
- pkg = spack.repo.get('multimethod@1')
+ pkg = spack.repo.get(pkg_name + '@1')
assert pkg.base_method() == "base_method"
-
-def test_multimethod_inheritance(mock_packages):
- pkg = spack.repo.get('multimethod-inheritor@1.0')
- assert pkg.no_version_2() == 1