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.
This commit is contained in:
45
scripts/run_tests.py
Normal file
45
scripts/run_tests.py
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test runner script for TheChart application.
|
||||
Run this script to execute all tests with coverage reporting.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def run_tests():
|
||||
"""Run all tests with coverage reporting."""
|
||||
|
||||
# Change to project root directory
|
||||
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
os.chdir(project_root)
|
||||
|
||||
print("Running TheChart tests with coverage...")
|
||||
print(f"Project root: {project_root}")
|
||||
|
||||
# Run pytest with coverage
|
||||
cmd = [
|
||||
sys.executable,
|
||||
"-m",
|
||||
"pytest",
|
||||
"tests/",
|
||||
"--verbose",
|
||||
"--cov=src",
|
||||
"--cov-report=term-missing",
|
||||
"--cov-report=html:htmlcov",
|
||||
"--cov-report=xml",
|
||||
]
|
||||
|
||||
try:
|
||||
result = subprocess.run(cmd, check=False)
|
||||
return result.returncode
|
||||
except Exception as e:
|
||||
print(f"Error running tests: {e}")
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = run_tests()
|
||||
sys.exit(exit_code)
|
||||
Reference in New Issue
Block a user