"""Root launcher — thicket.py must own every mode from any cwd.""" from __future__ import annotations import subprocess import sys from pathlib import Path LAUNCHER = Path(__file__).resolve().parents[1] / "thicket.py" def _run(args: list[str], cwd: Path) -> subprocess.CompletedProcess: return subprocess.run( [sys.executable, str(LAUNCHER), *args], capture_output=True, text=True, timeout=60, cwd=cwd, ) def test_launcher_version_from_project_root(): from thicket import __version__ result = _run(["--version"], LAUNCHER.parent) assert result.returncode == 0 assert result.stdout.strip() == f"thicket {__version__}" def test_launcher_version_from_unrelated_cwd(tmp_path): """By-path invocation must resolve the in-tree package anywhere.""" result = _run(["--version"], tmp_path) from thicket import __version__ assert result.returncode == 0 assert f"thicket {__version__}" in result.stdout def test_launcher_dry_run_reports_probe(): result = _run(["--dry-run"], LAUNCHER.parent) assert result.returncode == 0 assert "Thicket environment probe" in result.stdout assert "Qdrant:" in result.stdout and "Ollama:" in result.stdout