(fix) site_cache_dir() must return DVC_SITE_CACHE_DIR if it exists (#10776)

* DVC_SITE_CACHE_DIR must be sent first, deal with platformdirs afterwards

* Test should check default behaviour when no env var is set

* Add test: site_cache_dir() must return the env var if set
This commit is contained in:
Rodrigo Goya
2025-06-12 07:12:04 +00:00
committed by GitHub
parent b89cb893a1
commit 346b1c064e
2 changed files with 12 additions and 5 deletions
+8 -2
View File
@@ -3,7 +3,7 @@ import sys
import pytest
from dvc.dirs import global_config_dir, site_cache_dir
from dvc.env import DVC_GLOBAL_CONFIG_DIR
from dvc.env import DVC_GLOBAL_CONFIG_DIR, DVC_SITE_CACHE_DIR
def test_global_config_dir_respects_env_var(monkeypatch):
@@ -13,5 +13,11 @@ def test_global_config_dir_respects_env_var(monkeypatch):
@pytest.mark.skipif(sys.platform != "linux", reason="Only for Unix platforms")
def test_site_cache_dir_on_unix():
def test_site_cache_dir_on_unix(monkeypatch):
monkeypatch.delenv(DVC_SITE_CACHE_DIR, raising=False)
assert site_cache_dir() == "/var/tmp/dvc"
def test_site_cache_dir_env_var(monkeypatch):
monkeypatch.setenv(DVC_SITE_CACHE_DIR, "foo_bar")
assert site_cache_dir() == "foo_bar"