Add tests

This commit is contained in:
Pim van Pelt
2025-08-02 20:03:32 +02:00
parent 5eb76736cc
commit e2e65add2e
12 changed files with 1270 additions and 4 deletions

54
run_tests.py Executable file
View File

@@ -0,0 +1,54 @@
#!/usr/bin/env python3
"""
Test runner script for kumacli
Usage:
python run_tests.py # Run all tests
python run_tests.py --cov # Run tests with coverage
python run_tests.py tests/test_info.py # Run specific test file
"""
import sys
import subprocess
def run_tests(args=None):
"""Run pytest with optional arguments"""
# Use python3 explicitly for compatibility
cmd = ["python3", "-m", "pytest"]
if args:
cmd.extend(args)
else:
cmd.extend([
"tests/",
"-v",
"--tb=short"
])
try:
result = subprocess.run(cmd, check=True)
return result.returncode
except subprocess.CalledProcessError as e:
print(f"Tests failed with exit code: {e.returncode}")
return e.returncode
except FileNotFoundError:
print("pytest not found. Install with: pip install pytest")
return 1
def main():
"""Main entry point"""
if len(sys.argv) > 1:
# Pass through command line arguments
args = sys.argv[1:]
else:
args = None
exit_code = run_tests(args)
sys.exit(exit_code)
if __name__ == "__main__":
main()