Files
timmy-academy/run_tests.py
2026-04-26 13:06:11 -04:00

54 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Run the timmy-academy unit test suite.
Usage:
./run_tests.py # Run all tests with pytest
./run_tests.py -v # Verbose output
./run_tests.py --typeclasses # Only typeclass tests
./run_tests.py --commands # Only command tests
Requires: pytest (install via: pip install pytest)
"""
from __future__ import annotations
import subprocess
import sys
import os
def main():
# Ensure pytest is available
try:
import pytest # noqa
except ImportError:
print("ERROR: pytest not installed. Run: pip install pytest")
sys.exit(1)
# Build test path arguments
test_paths = ['tests']
args = sys.argv[1:]
# Convenience flags for running subsets
if '--typeclasses' in args:
args.remove('--typeclasses')
test_paths = ['tests/typeclasses']
if '--commands' in args:
args.remove('--commands')
test_paths = ['tests/commands']
if '--audited' in args:
args.remove('--audited')
test_paths = ['tests/typeclasses/test_audited_character.py']
if '--commands' in args:
args.remove('--commands')
test_paths = ['tests/commands/test_commands.py']
# Run pytest
cmd = ['pytest', '-v', '--tb=short'] + args + test_paths
print(f"Running: {' '.join(cmd)}")
result = subprocess.run(cmd)
sys.exit(result.returncode)
if __name__ == '__main__':
main()