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.
This commit is contained in:
		
				
					committed by
					
						
						Todd Gamblin
					
				
			
			
				
	
			
			
			
						parent
						
							88f97c07de
						
					
				
				
					commit
					5ce926d2d1
				
			@@ -23,22 +23,24 @@
 | 
			
		||||
# 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):
 | 
			
		||||
@pytest.mark.usefixtures('config', 'builtin_mock')
 | 
			
		||||
class TestPackage(object):
 | 
			
		||||
    def test_load_package(self):
 | 
			
		||||
        spack.repo.get('mpich')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_package_name(builtin_mock):
 | 
			
		||||
    def test_package_name(self):
 | 
			
		||||
        pkg = spack.repo.get('mpich')
 | 
			
		||||
        assert pkg.name == 'mpich'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_package_filename(builtin_mock):
 | 
			
		||||
    def test_package_filename(self):
 | 
			
		||||
        repo = Repo(spack.mock_packages_path)
 | 
			
		||||
        filename = repo.filename_for_package_name('mpich')
 | 
			
		||||
        assert filename == join_path(
 | 
			
		||||
@@ -48,8 +50,7 @@ def test_package_filename(builtin_mock):
 | 
			
		||||
            'package.py'
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_nonexisting_package_filename():
 | 
			
		||||
    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(
 | 
			
		||||
@@ -59,30 +60,26 @@ def test_nonexisting_package_filename():
 | 
			
		||||
            'package.py'
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_package_class_names():
 | 
			
		||||
    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(builtin_mock):
 | 
			
		||||
    def test_import_package(self):
 | 
			
		||||
        import spack.pkg.builtin.mock.mpich             # noqa
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_import_package_as(builtin_mock):
 | 
			
		||||
    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():
 | 
			
		||||
    def test_inheritance_of_diretives(self):
 | 
			
		||||
        p = spack.repo.get('simple-inheritance')
 | 
			
		||||
 | 
			
		||||
        # Check dictionaries that should have been filled by directives
 | 
			
		||||
@@ -107,23 +104,19 @@ def test_inheritance_of_diretives():
 | 
			
		||||
        assert '~openblas' in s
 | 
			
		||||
        assert 'mpi' in s
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_dependency_extensions():
 | 
			
		||||
    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(builtin_mock):
 | 
			
		||||
    def test_import_class_from_package(self):
 | 
			
		||||
        from spack.pkg.builtin.mock.mpich import Mpich  # noqa
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_import_module_from_package(builtin_mock):
 | 
			
		||||
    def test_import_module_from_package(self):
 | 
			
		||||
        from spack.pkg.builtin.mock import mpich        # noqa
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_import_namespace_container_modules(builtin_mock):
 | 
			
		||||
    def test_import_namespace_container_modules(self):
 | 
			
		||||
        import spack.pkg                                # noqa
 | 
			
		||||
        import spack.pkg as p                           # noqa
 | 
			
		||||
        from spack import pkg                           # noqa
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user