-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·93 lines (74 loc) · 2.45 KB
/
Copy pathrun_tests.py
File metadata and controls
executable file
·93 lines (74 loc) · 2.45 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
"""
Test runner script for AI Doc Read Studio
"""
import subprocess
import sys
import os
def run_tests():
"""Run the complete test suite."""
print("🧪 AI Doc Read Studio - Test Suite")
print("=" * 50)
# Ensure we're in the right directory
if not os.path.exists("tests"):
print("❌ Tests directory not found. Please run from project root.")
return 1
# Run pytest with coverage if available
try:
# Try to run with coverage first
result = subprocess.run([
"uv", "run", "pytest",
"tests/",
"-v",
"--tb=short",
"-x" # Stop on first failure
], capture_output=False)
if result.returncode == 0:
print("\n✅ All tests passed!")
print("\n🚀 Application is ready for use!")
print("Start with: python start_app.py")
else:
print(f"\n❌ Tests failed with exit code {result.returncode}")
print("Check the output above for details.")
return result.returncode
except FileNotFoundError:
print("❌ pytest not found. Make sure you've installed test dependencies:")
print(" uv add pytest pytest-asyncio")
return 1
except Exception as e:
print(f"❌ Error running tests: {e}")
return 1
def run_specific_test_file(test_file):
"""Run a specific test file."""
if not test_file.startswith("test_"):
test_file = f"test_{test_file}"
if not test_file.endswith(".py"):
test_file = f"{test_file}.py"
test_path = f"tests/{test_file}"
if not os.path.exists(test_path):
print(f"❌ Test file not found: {test_path}")
return 1
print(f"🧪 Running specific test: {test_file}")
print("=" * 50)
try:
result = subprocess.run([
"uv", "run", "pytest",
test_path,
"-v",
"--tb=short"
], capture_output=False)
return result.returncode
except Exception as e:
print(f"❌ Error running test: {e}")
return 1
def main():
"""Main entry point for test runner."""
if len(sys.argv) > 1:
# Run specific test file
test_file = sys.argv[1]
return run_specific_test_file(test_file)
else:
# Run all tests
return run_tests()
if __name__ == "__main__":
sys.exit(main())