diff --git a/lib/spack/spack/test/cmd/gpg.py b/lib/spack/spack/test/cmd/gpg.py index 08749022cab..c8dd8e00ca0 100644 --- a/lib/spack/spack/test/cmd/gpg.py +++ b/lib/spack/spack/test/cmd/gpg.py @@ -12,6 +12,7 @@ import spack.bootstrap import spack.util.executable import spack.util.gpg +import spack.paths from spack.main import SpackCommand from spack.paths import mock_gpg_data_path, mock_gpg_keys_path from spack.util.executable import ProcessError @@ -46,9 +47,9 @@ def test_find_gpg(cmd_name, version, tmpdir, mock_gnupghome, monkeypatch): monkeypatch.setenv("PATH", str(tmpdir)) if version == "undetectable" or version.endswith("1.3.4"): with pytest.raises(spack.util.gpg.SpackGPGError): - spack.util.gpg.init(force=True) + spack.util.gpg.init(force=True, gpg_path=spack.paths.gpg_path) else: - spack.util.gpg.init(force=True) + spack.util.gpg.init(force=True, gpg_path=spack.paths.gpg_path) assert spack.util.gpg.GPG is not None assert spack.util.gpg.GPGCONF is not None @@ -57,7 +58,7 @@ def test_no_gpg_in_path(tmpdir, mock_gnupghome, monkeypatch, mutable_config): monkeypatch.setenv("PATH", str(tmpdir)) bootstrap("disable") with pytest.raises(RuntimeError): - spack.util.gpg.init(force=True) + spack.util.gpg.init(force=True, gpg_path=spack.paths.gpg_path) @pytest.mark.maybeslow diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index c832c4d1d5d..350eb7c77f6 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -1074,7 +1074,7 @@ def mock_gnupghome(monkeypatch): # This comes up because tmp paths on macOS are already long-ish, and # pytest makes them longer. try: - spack.util.gpg.init() + spack.util.gpg.init(gpg_path=spack.paths.gpg_path) except spack.util.gpg.SpackGPGError: if not spack.util.gpg.GPG: pytest.skip("This test requires gpg") diff --git a/lib/spack/spack/test/util/util_gpg.py b/lib/spack/spack/test/util/util_gpg.py index 242d9fb9480..6cea2d01d92 100644 --- a/lib/spack/spack/test/util/util_gpg.py +++ b/lib/spack/spack/test/util/util_gpg.py @@ -7,12 +7,13 @@ import pytest +import spack.paths import spack.util.gpg @pytest.fixture() def has_socket_dir(): - spack.util.gpg.init() + spack.util.gpg.init(gpg_path=spack.paths.gpg_path) return bool(spack.util.gpg.SOCKET_DIR) diff --git a/lib/spack/spack/util/gpg.py b/lib/spack/spack/util/gpg.py index ea1e42131d9..b0a2c353062 100644 --- a/lib/spack/spack/util/gpg.py +++ b/lib/spack/spack/util/gpg.py @@ -8,8 +8,7 @@ import os import re -import spack.error -import spack.paths +import spack.util.error import spack.util.executable import spack.version @@ -29,7 +28,7 @@ def clear(): GPG, GPGCONF, SOCKET_DIR, GNUPGHOME = None, None, None, None -def init(gnupghome=None, force=False): +def init(gnupghome=None, force=False, gpg_path=None): """Initialize the global objects in the module, if not set. When calling any gpg executable, the GNUPGHOME environment @@ -56,7 +55,7 @@ def init(gnupghome=None, force=False): return # Set the value of GNUPGHOME to be used in this module - GNUPGHOME = gnupghome or os.getenv("SPACK_GNUPGHOME") or spack.paths.gpg_path + GNUPGHOME = gnupghome or os.getenv("SPACK_GNUPGHOME") or gpg_path # Set the executable objects for "gpg" and "gpgconf" with spack.bootstrap.ensure_bootstrap_configuration(): @@ -165,7 +164,7 @@ def _get_unimported_public_keys(output): return keys -class SpackGPGError(spack.error.SpackError): +class SpackGPGError(spack.util.error.UtilityError): """Class raised when GPG errors are detected."""