Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

test: isolate Jedi caches across pytest workers (#11601)

Shahmir Varqhabb54f586885d
diff --git a/tests/conftest.py b/tests/conftest.py
index 656fb30b17..d3665b6a58 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -51,6 +51,22 @@ register_formatters()
initialize_mimetypes()
[email protected](scope="session", autouse=True)
+def _isolate_jedi_cache(
+ tmp_path_factory: pytest.TempPathFactory,
+) -> Generator[None, None, None]:
+ import jedi
+
+ # Parso's disk cache writes are not atomic across pytest workers.
+ with pytest.MonkeyPatch.context() as monkeypatch:
+ monkeypatch.setattr(
+ jedi.settings,
+ "cache_directory",
+ str(tmp_path_factory.mktemp("jedi")),
+ )
+ yield
+
+
def pytest_collection_modifyitems(
config: pytest.Config, items: list[pytest.Item]
) -> None: