Spaces:
Running
Running
File size: 1,629 Bytes
d66ab65 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
#!/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()) |