Files
tampy/tests/test_cli.py

43 lines
1.1 KiB
Python

"""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", "test.tampy"],
capture_output=True,
text=True,
env={**dict(os.environ), "PYTHONPATH": "src"}
)
assert result.returncode == 0
assert "Generated:" in result.stdout
def test_run_command():
"""Test run command."""
result = subprocess.run(
[sys.executable, "-m", "tampy", "run", "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", "test.tampy"],
capture_output=True,
text=True,
env={**dict(os.environ), "PYTHONPATH": "src"}
)
assert result.returncode == 0
assert Path("test.py").exists()