Skip to content

Commit 0188eba

Browse files
Copilotshaypal5
andcommitted
Fix regression: only apply cache isolation in parallel (xdist) mode
Co-authored-by: shaypal5 <917954+shaypal5@users.noreply.github.com>
1 parent 065808c commit 0188eba

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tests/conftest.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,14 @@ def isolated_cache_directory(tmp_path, monkeypatch, request, worker_id):
104104
This is especially important for pickle and maxage tests when running in parallel. Each pytest-xdist worker gets its
105105
own cache directory to avoid conflicts.
106106
107+
Only applies when running in parallel mode (pytest-xdist), to avoid breaking tests that use module-level path
108+
constants computed from the default cache directory at import time.
109+
107110
"""
108-
if "pickle" in request.node.keywords or "maxage" in request.node.keywords:
109-
# Create a unique cache directory for this test
110-
cache_dir = tmp_path / "cachier_cache" if worker_id == "master" else tmp_path / f"cachier_cache_{worker_id}"
111+
if worker_id != "master" and (
112+
"pickle" in request.node.keywords or "maxage" in request.node.keywords
113+
):
114+
cache_dir = tmp_path / f"cachier_cache_{worker_id}"
111115

112116
cache_dir.mkdir(exist_ok=True, parents=True)
113117

0 commit comments

Comments
 (0)