File size: 1,302 Bytes
00e8372 6754f1c cf09ddc 00e8372 cf09ddc 00e8372 6754f1c cf09ddc 6754f1c cf09ddc 6754f1c cf09ddc 6754f1c cf09ddc 6754f1c cf09ddc 00e8372 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #!/usr/bin/env python3
"""Minimal test runner for demo project - no base dependencies."""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
def main() -> int:
"""Run pytest using demo's .venv."""
demo_root = Path(__file__).resolve().parent.parent
venv_python = demo_root / ".venv" / "bin" / "python"
if not venv_python.exists():
sys.stderr.write(f"Error: {venv_python} not found. Run module_setup.py first.\n")
return 1
tests_dir = demo_root / "tests"
if not tests_dir.exists():
sys.stderr.write(f"No tests directory found at {tests_dir}. Nothing to test.\n")
return 0
# Build pytest command with default args if none provided
cmd = [str(venv_python), "-m", "pytest"]
# Add default args only if no args provided
if len(sys.argv) == 1:
cmd.extend(
[
"tests/",
"-v",
"--cov=apps",
"--cov-report=term-missing",
]
)
else:
cmd.extend(sys.argv[1:])
try:
subprocess.run(cmd, cwd=str(demo_root), check=True)
return 0
except subprocess.CalledProcessError as exc:
return exc.returncode
if __name__ == "__main__":
raise SystemExit(main())
|