tests: isolate dvc config and directories (#9450)

* tests: isolate dvc config and directories

by introducing envvars to change default values. This lets pytest
handle the deletion of tmpdirs, instead of filling /var/tmp with
hundreds of thousands of directories. Also isolates test run from
faulty global/system config files.

* move to dvc/env and sort
This commit is contained in:
skshetry
2023-05-15 18:16:02 +05:45
committed by GitHub
parent 45181504ea
commit 004f49744e
5 changed files with 48 additions and 17 deletions
+7
View File
@@ -5,6 +5,7 @@ from contextlib import suppress
import pytest
from dvc import env
from dvc.testing.fixtures import * # noqa, pylint: disable=wildcard-import
from .dir_helpers import * # noqa, pylint: disable=wildcard-import
@@ -206,7 +207,13 @@ defaultBranch=master
import pygit2
pygit2.settings.search_path[pygit2.GIT_CONFIG_LEVEL_GLOBAL] = str(home_dir)
monkeypatch.setenv(env.DVC_SYSTEM_CONFIG_DIR, os.fspath(path / "system"))
monkeypatch.setenv(env.DVC_GLOBAL_CONFIG_DIR, os.fspath(path / "global"))
monkeypatch.setenv(env.DVC_SITE_CACHE_DIR, os.fspath(path / "site_cache_dir"))
yield
monkeypatch.undo()