Files
thechart/scripts/quick_test.py
William Valentin a521ed6e9a
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
Add quick test runner and enhance run_tests script
- Introduced `quick_test.py` for running specific test categories (unit, integration, theme, all).
- Updated `run_tests.py` to improve test execution and reporting, including coverage.
- Removed outdated test scripts for keyboard shortcuts, menu theming, note saving, and entry updating.
- Added new test script `test_theme_changing.py` to verify theme changing functionality.
- Consolidated integration tests into `test_integration.py` for comprehensive testing of TheChart application.
- Updated theme manager to ensure color retrieval works correctly.
- Modified test constants to import from the correct module path.
2025-08-05 15:09:13 -07:00

90 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""
Quick test runner for individual test categories.
Usage:
python scripts/quick_test.py unit # Run only unit tests
python scripts/quick_test.py integration # Run only integration tests
python scripts/quick_test.py theme # Test theme functionality
python scripts/quick_test.py all # Run all tests (default)
"""
import subprocess
import sys
from pathlib import Path
def run_unit_tests():
"""Run unit tests only."""
cmd = [sys.executable, "-m", "pytest", "tests/", "--verbose", "-x", "--tb=short"]
return subprocess.run(cmd).returncode == 0
def run_integration_tests():
"""Run integration tests only."""
cmd = [
sys.executable,
"-m",
"pytest",
"tests/test_integration.py",
"--verbose",
"-s",
]
return subprocess.run(cmd).returncode == 0
def run_theme_tests():
"""Run theme-related tests only."""
cmd = [
sys.executable,
"-m",
"pytest",
"tests/test_integration.py::TestIntegrationSuite::test_theme_changing_functionality",
"tests/test_integration.py::TestIntegrationSuite::test_menu_theming_integration",
"tests/test_theme_manager.py",
"--verbose",
"-s",
]
return subprocess.run(cmd).returncode == 0
def run_all_tests():
"""Run the full test suite."""
return subprocess.run([sys.executable, "scripts/run_tests.py"]).returncode == 0
def main():
"""Main test runner."""
# Change to project root
project_root = Path(__file__).parent.parent
import os
os.chdir(project_root)
test_type = sys.argv[1] if len(sys.argv) > 1 else "all"
runners = {
"unit": run_unit_tests,
"integration": run_integration_tests,
"theme": run_theme_tests,
"all": run_all_tests,
}
if test_type not in runners:
print(f"Unknown test type: {test_type}")
print("Available options: unit, integration, theme, all")
sys.exit(1)
print(f"Running {test_type} tests...")
success = runners[test_type]()
if success:
print(f"{test_type.title()} tests passed!")
sys.exit(0)
else:
print(f"{test_type.title()} tests failed!")
sys.exit(1)
if __name__ == "__main__":
main()