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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix(tests): isolate test_project_dependencies from pyproject.toml pollution (#9634)
Myles Scolnickcd40f732ed04
diff --git a/tests/conftest.py b/tests/conftest.pyindex bf5e2c29ef..657afcd9e2 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -80,6 +80,31 @@ def pytest_collection_modifyitems(item.add_marker(pytest.mark.skip(reason=reason))+# Captured at conftest import time (i.e. at worker startup, before any test+# runs on any xdist worker), so the on-disk file can be mutated mid-session by+# a leaking `uv add` without corrupting `tests/test_project_dependencies.py`.+_PYPROJECT_PATH = Path(__file__).parent.parent / "pyproject.toml"+_PYPROJECT_TEXT_AT_SESSION_START = (+ _PYPROJECT_PATH.read_text() if _PYPROJECT_PATH.is_file() else None+)++[email protected](scope="session")+def pyproject_text() -> str:+ """`pyproject.toml` content as it was at session start.++ Use this instead of reading `pyproject.toml` directly in tests so the+ read is immune to mid-session mutations by parallel tests (e.g. a+ leaking real `uv add`).+ """+ if _PYPROJECT_TEXT_AT_SESSION_START is None:+ pytest.fail(+ f"pyproject.toml not found at {_PYPROJECT_PATH} when conftest "+ f"was imported."+ )+ return _PYPROJECT_TEXT_AT_SESSION_START++@pytest.fixture(scope="session")def _venv_canary_path() -> Path | None:"""Resolve an on-disk file whose existence signals the test venv is intact.diff --git a/tests/test_project_dependencies.py b/tests/test_project_dependencies.pyindex 52a3b1e0fb..83cd013a06 100644--- a/tests/test_project_dependencies.py+++ b/tests/test_project_dependencies.py@@ -1,7 +1,5 @@from __future__ import annotations-from pathlib import Path-import pytestfrom tests.mocks import snapshotter@@ -9,15 +7,10 @@ from tests.mocks import snapshottersnapshot = snapshotter(__file__)-def _load_pyproject():+def test_required_dependencies(pyproject_text: str) -> None:import tomlkit- pyproject_path = Path(__file__).parent.parent / "pyproject.toml"- return tomlkit.loads(pyproject_path.read_text())---def test_required_dependencies():- pyproject = _load_pyproject()+ pyproject = tomlkit.loads(pyproject_text)deps = sorted(pyproject["project"]["dependencies"])snapshot("dependencies.txt", "\n".join(deps), keep_version=True)@@ -26,8 +19,10 @@ def test_required_dependencies():"extra",["sql", "sandbox", "recommended", "lsp", "mcp"],)-def test_optional_dependencies(extra: str):- pyproject = _load_pyproject()+def test_optional_dependencies(extra: str, pyproject_text: str) -> None:+ import tomlkit++ pyproject = tomlkit.loads(pyproject_text)deps = sorted(pyproject["project"]["optional-dependencies"][extra])snapshot(f"optional-dependencies-{extra}.txt",