diff --git a/tests/conftest.py b/tests/conftest.py index d138449e..e2657784 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -104,10 +104,12 @@ def isolated_cache_directory(tmp_path, monkeypatch, request, worker_id): This is especially important for pickle and maxage tests when running in parallel. Each pytest-xdist worker gets its own cache directory to avoid conflicts. + Only applies when running in parallel mode (pytest-xdist), to avoid breaking tests that use module-level path + constants computed from the default cache directory at import time. + """ - if "pickle" in request.node.keywords or "maxage" in request.node.keywords: - # Create a unique cache directory for this test - cache_dir = tmp_path / "cachier_cache" if worker_id == "master" else tmp_path / f"cachier_cache_{worker_id}" + if worker_id != "master" and ("pickle" in request.node.keywords or "maxage" in request.node.keywords): + cache_dir = tmp_path / f"cachier_cache_{worker_id}" cache_dir.mkdir(exist_ok=True, parents=True)