Skip to content

Commit 78524b5

Browse files
test: switch zero-dep install tests to uv venv (#14)
stdlib `venv.create(..., with_pip=True)` calls `python -m ensurepip` inside the new venv, which aborts with SIGABRT on cpython 3.11.14 macOS-aarch64. None of the 5 tests in test_zero_dep_install.py could run as a result. Switch to `uv venv` + `uv pip install --python <venv-python>`. uv has its own resolver and does not depend on ensurepip, so it works on this Python build, runs faster, and matches the rest of the project's tooling. Skip the suite (rather than fail) on machines without uv. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent b5d6a16 commit 78524b5

1 file changed

Lines changed: 34 additions & 27 deletions

File tree

tests/test_zero_dep_install.py

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,60 @@
99
1010
This guards the architectural contract documented in ``tech.md``
1111
ADR-002. Marked ``slow`` because it creates a real venv.
12+
13+
Uses ``uv venv`` + ``uv pip`` rather than stdlib ``venv``/``pip`` because
14+
``ensurepip`` aborts on some Python builds (observed on cpython 3.11.14
15+
macOS-aarch64).
1216
"""
1317

1418
from __future__ import annotations
1519

20+
import shutil
1621
import subprocess
1722
import sys
18-
import venv
1923
from pathlib import Path
2024

2125
import pytest
2226

2327
REPO_ROOT = Path(__file__).resolve().parent.parent
2428

29+
_UV = shutil.which("uv")
2530

26-
@pytest.mark.slow
27-
@pytest.mark.skipif(
28-
sys.platform.startswith("win"),
29-
reason="venv layout differs on Windows; covered on Linux/macOS",
31+
_requires_uv = pytest.mark.skipif(
32+
_UV is None,
33+
reason="uv is required to build the isolated test venv (stdlib ensurepip is unreliable)",
3034
)
31-
def test_attune_help_imports_without_authoring_extra(tmp_path: Path) -> None:
32-
venv_dir = tmp_path / "venv"
33-
venv.create(venv_dir, with_pip=True)
34-
py = venv_dir / "bin" / "python"
35-
pip = venv_dir / "bin" / "pip"
3635

36+
37+
def _make_venv(venv_dir: Path) -> Path:
38+
"""Create a venv at ``venv_dir`` via ``uv venv`` and return its python."""
3739
subprocess.run(
38-
[str(pip), "install", "--quiet", "python-frontmatter"],
40+
[_UV, "venv", "--quiet", str(venv_dir)],
3941
check=True,
4042
capture_output=True,
4143
)
44+
return venv_dir / "bin" / "python"
45+
46+
47+
def _install(py: Path, *args: str) -> None:
4248
subprocess.run(
43-
[str(pip), "install", "--quiet", "--no-deps", "-e", str(REPO_ROOT)],
49+
[_UV, "pip", "install", "--quiet", "--python", str(py), *args],
4450
check=True,
4551
capture_output=True,
4652
)
4753

54+
55+
@pytest.mark.slow
56+
@_requires_uv
57+
@pytest.mark.skipif(
58+
sys.platform.startswith("win"),
59+
reason="venv layout differs on Windows; covered on Linux/macOS",
60+
)
61+
def test_attune_help_imports_without_authoring_extra(tmp_path: Path) -> None:
62+
py = _make_venv(tmp_path / "venv")
63+
_install(py, "python-frontmatter")
64+
_install(py, "--no-deps", "-e", str(REPO_ROOT))
65+
4866
base = subprocess.run(
4967
[str(py), "-c", "import attune_help; print('ok')"],
5068
capture_output=True,
@@ -55,6 +73,7 @@ def test_attune_help_imports_without_authoring_extra(tmp_path: Path) -> None:
5573

5674

5775
@pytest.mark.slow
76+
@_requires_uv
5877
@pytest.mark.skipif(
5978
sys.platform.startswith("win"),
6079
reason="venv layout differs on Windows; covered on Linux/macOS",
@@ -69,21 +88,9 @@ def test_attune_help_imports_without_authoring_extra(tmp_path: Path) -> None:
6988
],
7089
)
7190
def test_shim_imports_fail_helpfully_without_authoring(tmp_path: Path, shim_module: str) -> None:
72-
venv_dir = tmp_path / "venv"
73-
venv.create(venv_dir, with_pip=True)
74-
py = venv_dir / "bin" / "python"
75-
pip = venv_dir / "bin" / "pip"
76-
77-
subprocess.run(
78-
[str(pip), "install", "--quiet", "python-frontmatter"],
79-
check=True,
80-
capture_output=True,
81-
)
82-
subprocess.run(
83-
[str(pip), "install", "--quiet", "--no-deps", "-e", str(REPO_ROOT)],
84-
check=True,
85-
capture_output=True,
86-
)
91+
py = _make_venv(tmp_path / "venv")
92+
_install(py, "python-frontmatter")
93+
_install(py, "--no-deps", "-e", str(REPO_ROOT))
8794

8895
result = subprocess.run(
8996
[str(py), "-c", f"import {shim_module}"],

0 commit comments

Comments
 (0)