"""Test CLI functionality.""" import os import subprocess import sys from pathlib import Path def test_build_command(): """Test build command.""" result = subprocess.run( [sys.executable, "-m", "tampy", "build", "tests/test.tampy"], capture_output=True, text=True, env={**dict(os.environ), "PYTHONPATH": "src"} ) assert result.returncode == 0 assert "Generated:" in result.stdout assert Path("tests/test.py").exists() def test_run_command(): """Test run command.""" result = subprocess.run( [sys.executable, "-m", "tampy", "run", "tests/test.tampy"], capture_output=True, text=True, env={**dict(os.environ), "PYTHONPATH": "src"} ) assert result.returncode == 0 assert "y is greater" in result.stdout def test_file_extension_replacement(): """Test that .tampy is replaced with .py.""" result = subprocess.run( [sys.executable, "-m", "tampy", "build", "tests/test.tampy"], capture_output=True, text=True, env={**dict(os.environ), "PYTHONPATH": "src"} ) assert result.returncode == 0 assert Path("tests/test.py").exists()