-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_unit_tests.py
More file actions
54 lines (46 loc) · 1.39 KB
/
run_unit_tests.py
File metadata and controls
54 lines (46 loc) · 1.39 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
#!/usr/bin/env python
"""Run unit tests in batches to avoid timeout."""
import subprocess
import sys
import json
test_modules = [
"tests/test_models.py",
"tests/test_service_registry.py",
"tests/test_dependency_manager.py",
"tests/test_circuit_breaker.py",
"tests/test_tracing.py",
"tests/test_chaos_controller.py"
]
all_passed = True
for module in test_modules:
print(f"\nRunning {module}...")
result = subprocess.run([
sys.executable, "-m", "pytest", module, "-v", "--tb=short"
], capture_output=True, text=True)
print(result.stdout)
if result.returncode != 0:
print(result.stderr)
all_passed = False
# Now run all tests with JSON report
print("\nGenerating JSON report...")
result = subprocess.run([
sys.executable, "-m", "pytest",
*test_modules,
"--json-report",
"--json-report-file=pytest_results.json",
"-q"
], capture_output=True, text=True)
print(result.stdout)
if result.returncode != 0:
print(result.stderr)
# Check test count
try:
with open("pytest_results.json", "r") as f:
report = json.load(f)
total_tests = report["summary"]["total"]
print(f"\nTotal tests: {total_tests}")
if total_tests < 100:
print(f"WARNING: Only {total_tests} tests found, need at least 100")
except Exception as e:
print(f"Error reading report: {e}")
sys.exit(0 if all_passed else 1)