-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
78 lines (60 loc) · 2.06 KB
/
run_tests.py
File metadata and controls
78 lines (60 loc) · 2.06 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
"""Test runner script for the Vector Bot project."""
import sys
import subprocess
from pathlib import Path
def run_command(cmd, description):
"""Run a command and display results."""
print(f"\n{'='*60}")
print(f"Running: {description}")
print(f"Command: {' '.join(cmd)}")
print(f"{'='*60}")
result = subprocess.run(cmd, capture_output=False)
return result.returncode == 0
def main():
"""Main test runner."""
project_root = Path(__file__).parent
# Change to project directory
import os
os.chdir(project_root)
success = True
# Run unit tests
if not run_command([
sys.executable, "-m", "pytest",
"tests/unit/",
"-v",
"--tb=short"
], "Unit Tests"):
success = False
# Run integration tests (may be skipped if dependencies missing)
if not run_command([
sys.executable, "-m", "pytest",
"tests/integration/",
"-v",
"--tb=short"
], "Integration Tests"):
print("\nNote: Integration tests may have been skipped due to missing dependencies")
# Run tests with coverage if coverage is available
try:
subprocess.run([sys.executable, "-c", "import coverage"],
check=True, capture_output=True)
run_command([
sys.executable, "-m", "pytest",
"tests/unit/",
"--cov=rag",
"--cov-report=term-missing",
"--cov-report=html"
], "Unit Tests with Coverage")
print("\nCoverage report generated in htmlcov/index.html")
except (subprocess.CalledProcessError, FileNotFoundError):
print("\nCoverage not available. Install with: pip install pytest-cov")
# Summary
print(f"\n{'='*60}")
if success:
print("✅ Test run completed successfully!")
else:
print("❌ Some tests failed. See output above for details.")
print(f"{'='*60}")
return 0 if success else 1
if __name__ == "__main__":
sys.exit(main())