diff options
Diffstat (limited to 'lib/spack/spack/test/conftest.py')
-rw-r--r-- | lib/spack/spack/test/conftest.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 8bd8deadce..1efdd6ba95 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -375,6 +375,19 @@ def linux_os(): @pytest.fixture(scope='session') +def default_config(): + """Isolates the default configuration from the user configs. + + This ensures we can test the real default configuration without having + tests fail when the user overrides the defaults that we test against.""" + defaults_path = os.path.join(spack.paths.etc_path, 'spack', 'defaults') + defaults_scope = spack.config.ConfigScope('defaults', defaults_path) + defaults_config = spack.config.Configuration(defaults_scope) + with use_configuration(defaults_config): + yield defaults_config + + +@pytest.fixture(scope='session') def configuration_dir(tmpdir_factory, linux_os): """Copies mock configuration files in a temporary directory. Returns the directory path. @@ -436,6 +449,19 @@ def mutable_config(tmpdir_factory, configuration_dir): yield cfg +@pytest.fixture(scope='function') +def mutable_empty_config(tmpdir_factory, configuration_dir): + """Empty configuration that can be modified by the tests.""" + mutable_dir = tmpdir_factory.mktemp('mutable_config').join('tmp') + + cfg = spack.config.Configuration( + *[spack.config.ConfigScope(name, str(mutable_dir.join(name))) + for name in ['site', 'system', 'user']]) + + with use_configuration(cfg): + yield cfg + + @pytest.fixture() def mock_low_high_config(tmpdir): """Mocks two configuration scopes: 'low' and 'high'.""" |