tokenizers / run_tests.py
bartar's picture
Upload 26 files
d66ab65 verified
#!/usr/bin/env python3
"""
Test runner script for Tokenizer Pro
Usage:
python run_tests.py # Run all tests
python run_tests.py unit # Run only unit tests
python run_tests.py integration # Run only integration tests
python run_tests.py --coverage # Run with coverage report
"""
import sys
import subprocess
import os
def run_command(cmd):
"""Run a command and return the exit code."""
print(f"Running: {' '.join(cmd)}")
return subprocess.call(cmd)
def main():
"""Main test runner function."""
args = sys.argv[1:]
# Base pytest command
pytest_cmd = ["python", "-m", "pytest"]
# Parse arguments
if "--coverage" in args:
pytest_cmd.extend(["--cov=app", "--cov-report=html", "--cov-report=term"])
args.remove("--coverage")
if "unit" in args:
pytest_cmd.extend([
"tests/test_tokenizer_service.py",
"tests/test_stats_service.py",
"tests/test_file_service.py",
"tests/test_validators.py"
])
elif "integration" in args:
pytest_cmd.append("tests/test_routes.py")
else:
# Run all tests
pytest_cmd.append("tests/")
# Add any remaining arguments
pytest_cmd.extend(args)
# Run the tests
exit_code = run_command(pytest_cmd)
if exit_code == 0:
print("\n✅ All tests passed!")
else:
print(f"\n❌ Tests failed with exit code {exit_code}")
return exit_code
if __name__ == "__main__":
sys.exit(main())