Files
thechart/scripts/test.py
William Valentin 4c7da343eb feat: Add test scripts and runner for TheChart application
- Created demo_failing_test.py to demonstrate pre-commit blocking with a failing test.
- Added run_tests.py for executing all tests with coverage reporting.
- Introduced test.py as a quick test runner for the application, providing coverage reports and user-friendly output.
2025-07-28 18:21:40 -07:00

52 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Quick test runner for TheChart application.
This script provides a simple way to run the test suite.
"""
import os
import subprocess
import sys
def main():
"""Run the test suite."""
print("🧪 Running TheChart Test Suite")
print("=" * 50)
# Change to project directory
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Run tests with coverage
cmd = [
"uv",
"run",
"pytest",
"tests/",
"--cov=src",
"--cov-report=term-missing",
"--cov-report=html:htmlcov",
"-v",
]
try:
result = subprocess.run(cmd, check=False)
if result.returncode == 0:
print("\n✅ All tests passed!")
else:
print(f"\n❌ Some tests failed (exit code: {result.returncode})")
print("\n📊 Coverage report generated in htmlcov/index.html")
return result.returncode
except KeyboardInterrupt:
print("\n⚠️ Tests interrupted by user")
return 1
except Exception as e:
print(f"\n💥 Error running tests: {e}")
return 1
if __name__ == "__main__":
sys.exit(main())