-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
77 lines (69 loc) · 2.23 KB
/
run_tests.py
File metadata and controls
77 lines (69 loc) · 2.23 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
#!/usr/bin/env python3
"""
Test runner for Letta Chat Client
Runs all tests with coverage reporting
"""
import subprocess
import sys
import os
from pathlib import Path
def run_tests():
"""Run the test suite with coverage"""
print("=" * 60)
print(" LETTA CHAT CLIENT - TEST SUITE")
print("=" * 60)
print()
# Check if we're in a virtual environment
if not hasattr(sys, 'real_prefix') and not (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix):
print("Warning: Not running in a virtual environment")
print("Consider running: python -m venv venv && .\\venv\\Scripts\\activate")
print()
# Run pytest with coverage
cmd = [
sys.executable, "-m", "pytest",
"tests/",
"--verbose",
"--tb=short",
"--cov=.",
"--cov-report=term-missing",
"--cov-report=html:htmlcov"
]
print("Running tests...")
print(f"Command: {' '.join(cmd)}")
print()
try:
result = subprocess.run(cmd, check=True)
print()
print("=" * 60)
print(" ALL TESTS PASSED! OK")
print("=" * 60)
print()
print("Coverage report generated in htmlcov/index.html")
return True
except subprocess.CalledProcessError as e:
print()
print("=" * 60)
print(" TESTS FAILED! ERROR")
print("=" * 60)
print(f"Exit code: {e.returncode}")
return False
except FileNotFoundError:
print("Error: pytest not found. Install test dependencies:")
print("pip install -r requirements-test.txt")
return False
def install_test_deps():
"""Install test dependencies"""
print("Installing test dependencies...")
try:
subprocess.run([sys.executable, "-m", "pip", "install", "-r", "requirements-test.txt"], check=True)
print("Test dependencies installed successfully!")
return True
except subprocess.CalledProcessError as e:
print(f"Failed to install test dependencies: {e}")
return False
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "--install":
success = install_test_deps()
else:
success = run_tests()
sys.exit(0 if success else 1)