diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py index 4734b4b9909..6cdfd4c72ef 100644 --- a/lib/spack/spack/__init__.py +++ b/lib/spack/spack/__init__.py @@ -38,18 +38,12 @@ # TODO: Below code should not import modules other than spack.config #----------------------------------------------------------------------------- import spack.config -from spack.util.path import canonicalize_path # TODO: get this out of __init__.py binary_cache_retrieved_specs = set() -#: Directories where to search for templates -template_dirs = spack.config.get('config:template_dirs') -template_dirs = [canonicalize_path(x) for x in template_dirs] - - # If this is True, spack will not clean the environment to remove # potentially harmful variables before builds. dirty = spack.config.get('config:dirty', False) diff --git a/lib/spack/spack/tengine.py b/lib/spack/spack/tengine.py index d49b4c69b22..731ce787824 100644 --- a/lib/spack/spack/tengine.py +++ b/lib/spack/spack/tengine.py @@ -22,13 +22,14 @@ # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## - import textwrap import jinja2 import llnl.util.lang import six -import spack + +import spack.config +from spack.util.path import canonicalize_path TemplateNotFound = jinja2.TemplateNotFound @@ -90,7 +91,8 @@ def make_environment(dirs=None): """Returns an configured environment for template rendering.""" if dirs is None: # Default directories where to search for templates - dirs = spack.template_dirs + dirs = [canonicalize_path(d) + for d in spack.config.get('config:template_dirs')] # Loader for the templates loader = jinja2.FileSystemLoader(dirs) # Environment of the template engine diff --git a/lib/spack/spack/test/modules/conftest.py b/lib/spack/spack/test/modules/conftest.py index 6fb9a4d3681..6cf6f7e1a53 100644 --- a/lib/spack/spack/test/modules/conftest.py +++ b/lib/spack/spack/test/modules/conftest.py @@ -90,14 +90,6 @@ def _impl(spec_str): return _impl -@pytest.fixture() -def update_template_dirs(config, monkeypatch): - """Mocks the template directories for tests""" - dirs = spack.config.get('config:template_dirs') - dirs = [spack.util.path.canonicalize_path(x) for x in dirs] - monkeypatch.setattr(spack, 'template_dirs', dirs) - - @pytest.fixture() def patch_configuration(monkeypatch, request): """Reads a configuration file from the mock ones prepared for tests diff --git a/lib/spack/spack/test/modules/dotkit.py b/lib/spack/spack/test/modules/dotkit.py index d471674f27f..71c253b4795 100644 --- a/lib/spack/spack/test/modules/dotkit.py +++ b/lib/spack/spack/test/modules/dotkit.py @@ -45,7 +45,6 @@ def test_dotkit(self, modulefile_content, patch_configuration): assert '#d mpileaks @2.3' in content assert len([x for x in content if 'dk_op' in x]) == 2 - @pytest.mark.usefixtures('update_template_dirs') def test_override_template_in_package( self, modulefile_content, patch_configuration ): @@ -56,7 +55,6 @@ def test_override_template_in_package( assert 'Override successful!' in content - @pytest.mark.usefixtures('update_template_dirs') def test_override_template_in_modules_yaml( self, modulefile_content, patch_configuration ): diff --git a/lib/spack/spack/test/modules/lmod.py b/lib/spack/spack/test/modules/lmod.py index 11ebf0302a9..9405c68062b 100644 --- a/lib/spack/spack/test/modules/lmod.py +++ b/lib/spack/spack/test/modules/lmod.py @@ -213,7 +213,6 @@ def test_non_virtual_in_hierarchy(self, factory, patch_configuration): with pytest.raises(spack.modules.lmod.NonVirtualInHierarchyError): module.write() - @pytest.mark.usefixtures('update_template_dirs') def test_override_template_in_package( self, modulefile_content, patch_configuration ): @@ -224,7 +223,6 @@ def test_override_template_in_package( assert 'Override successful!' in content - @pytest.mark.usefixtures('update_template_dirs') def test_override_template_in_modules_yaml( self, modulefile_content, patch_configuration ): diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py index 753cd57ddcf..8eb9c918dd0 100644 --- a/lib/spack/spack/test/modules/tcl.py +++ b/lib/spack/spack/test/modules/tcl.py @@ -241,7 +241,6 @@ def test_setup_environment(self, modulefile_content, patch_configuration): [x for x in content if 'setenv FOOBAR "callpath"' in x] ) == 1 - @pytest.mark.usefixtures('update_template_dirs') def test_override_template_in_package( self, modulefile_content, patch_configuration ): @@ -252,7 +251,6 @@ def test_override_template_in_package( assert 'Override successful!' in content - @pytest.mark.usefixtures('update_template_dirs') def test_override_template_in_modules_yaml( self, modulefile_content, patch_configuration ): @@ -265,7 +263,6 @@ def test_override_template_in_modules_yaml( content = modulefile_content('mpileaks arch=x86-linux') assert 'Override even better!' in content - @pytest.mark.usefixtures('update_template_dirs') def test_extend_context( self, modulefile_content, patch_configuration ):