diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index c579e67f819..19b53c05737 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -3236,20 +3236,3 @@ def test_relative_view_path_on_command_line_is_made_absolute(tmpdir, config): env("create", "--with-view", "view", "--dir", "env") environment = ev.Environment(os.path.join(".", "env")) assert os.path.samefile("view", environment.default_view.root) - - -def test_environment_created_in_users_location(mutable_config, tmpdir): - """Test that an environment is created in a location based on the config""" - spack.config.set("config:environments_root", str(tmpdir.join("envs"))) - env_dir = spack.config.get("config:environments_root") - - assert tmpdir.strpath in env_dir - assert not os.path.isdir(env_dir) - - dir_name = "user_env" - env("create", dir_name) - out = env("list") - - assert dir_name in out - assert env_dir in ev.root(dir_name) - assert os.path.isdir(os.path.join(env_dir, dir_name)) diff --git a/lib/spack/spack/test/cmd/mirror.py b/lib/spack/spack/test/cmd/mirror.py index bbbed81e75d..a6f88307347 100644 --- a/lib/spack/spack/test/cmd/mirror.py +++ b/lib/spack/spack/test/cmd/mirror.py @@ -37,7 +37,7 @@ def test_regression_8083(tmpdir, capfd, mock_packages, mock_fetch, config): @pytest.mark.regression("12345") def test_mirror_from_env(tmpdir, mock_packages, mock_fetch, config, mutable_mock_env_path): - mirror_dir = str(tmpdir.join("mirror_dir")) + mirror_dir = str(tmpdir) env_name = "test" env("create", env_name) diff --git a/lib/spack/spack/test/cmd/uninstall.py b/lib/spack/spack/test/cmd/uninstall.py index cf976d2673a..bd1e8a1b497 100644 --- a/lib/spack/spack/test/cmd/uninstall.py +++ b/lib/spack/spack/test/cmd/uninstall.py @@ -225,17 +225,8 @@ class TestUninstallFromEnv(object): @pytest.fixture def environment_setup( - self, - mutable_mock_env_path, - config, - mock_packages, - mutable_database, - install_mockery, - tmpdir, + self, mutable_mock_env_path, config, mock_packages, mutable_database, install_mockery ): - # make environments local to each instantiation of the fixture so they don't clash - # in parallel - spack.config.set("config:environments_root", str(tmpdir.join("envs"))) TestUninstallFromEnv.env("create", "e1") e1 = spack.environment.read("e1") with e1: diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py index bda5214a373..1c798f2abcc 100644 --- a/lib/spack/spack/test/config.py +++ b/lib/spack/spack/test/config.py @@ -1027,7 +1027,6 @@ def test_good_env_yaml(tmpdir): config: verify_ssl: False dirty: False - environments_root: ~/my/env/location repos: - ~/my/repo/location mirrors: @@ -1455,7 +1454,7 @@ def test_config_file_read_perms_failure(tmpdir, mutable_empty_config): def test_config_file_read_invalid_yaml(tmpdir, mutable_empty_config): """Test reading a configuration file with invalid (unparseable) YAML raises a ConfigFileError.""" - filename = tmpdir.join("test.yaml") + filename = join_path(tmpdir.strpath, "test.yaml") with open(filename, "w") as f: f.write("spack:\nview") diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index b5ef506ce6a..bf6e4e6b357 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -1551,14 +1551,14 @@ def get_rev(): yield t -@pytest.fixture(scope="function") -def mutable_mock_env_path(tmpdir, mutable_config): +@pytest.fixture() +def mutable_mock_env_path(tmpdir_factory): """Fixture for mocking the internal spack environments directory.""" - saved_path = ev.environment.default_env_path - mock_path = tmpdir.join("mock-env-path") - ev.environment.default_env_path = str(mock_path) + saved_path = ev.environment.env_path + mock_path = tmpdir_factory.mktemp("mock-env-path") + ev.environment.env_path = str(mock_path) yield mock_path - ev.environment.default_env_path = saved_path + ev.environment.env_path = saved_path @pytest.fixture() diff --git a/lib/spack/spack/test/env.py b/lib/spack/spack/test/env.py index 5c2d0433746..83538e7d717 100644 --- a/lib/spack/spack/test/env.py +++ b/lib/spack/spack/test/env.py @@ -108,24 +108,6 @@ def test_env_change_spec_in_matrix_raises_error( assert "Cannot directly change specs in matrices" in str(error) -def test_environment_cant_modify_environments_root(tmpdir): - filename = str(tmpdir.join("spack.yaml")) - with open(filename, "w") as f: - f.write( - """\ -spack: - config: - environments_root: /a/black/hole - view: false - specs: [] -""" - ) - with tmpdir.as_cwd(): - with pytest.raises(ev.SpackEnvironmentError): - e = ev.Environment(tmpdir.strpath) - ev.activate(e) - - def test_activate_should_require_an_env(): with pytest.raises(TypeError): ev.activate(env="name") diff --git a/lib/spack/spack/test/util/spack_yaml.py b/lib/spack/spack/test/util/spack_yaml.py index 03b53bbd65f..3c8c48a2bbc 100644 --- a/lib/spack/spack/test/util/spack_yaml.py +++ b/lib/spack/spack/test/util/spack_yaml.py @@ -38,12 +38,7 @@ def check_blame(element, file_name, line=None): if line is not None: annotation += ":%d" % line - try: - assert file_name in element_line - except Exception: - print(output) - finally: - assert file_name in element_line + assert file_name in element_line def test_config_blame(config):