-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
129 lines (99 loc) · 3.05 KB
/
run_tests.py
File metadata and controls
129 lines (99 loc) · 3.05 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env python
"""
Test Runner Script - Flowfull-Python Client
This file is part of Flowfull-Python Client.
License: AGPL-3.0-or-later
Usage:
python run_tests.py # Run all tests
python run_tests.py --cov # Run with coverage
python run_tests.py --verbose # Run with verbose output
python run_tests.py --fast # Skip slow tests
"""
import sys
import subprocess
from pathlib import Path
def check_pytest_installed():
"""Check if pytest is installed"""
try:
result = subprocess.run(
[sys.executable, "-m", "pytest", "--version"],
capture_output=True,
text=True
)
return result.returncode == 0
except Exception:
return False
def install_dependencies():
"""Install test dependencies"""
print("📦 Installing test dependencies...")
print()
result = subprocess.run(
[sys.executable, "-m", "pip", "install", "-r", "requirements-dev.txt"],
cwd=Path(__file__).parent
)
return result.returncode == 0
def run_tests(args=None):
"""Run pytest with specified arguments"""
if args is None:
args = []
# Base pytest command - use python -m pytest for better compatibility
cmd = [sys.executable, "-m", "pytest"]
# Add arguments
cmd.extend(args)
# Run pytest
result = subprocess.run(cmd, cwd=Path(__file__).parent)
return result.returncode
def main():
"""Main entry point"""
args = sys.argv[1:]
# Check if pytest is installed
if not check_pytest_installed():
print("⚠️ pytest is not installed!")
print()
response = input("Do you want to install test dependencies now? (y/n): ")
if response.lower() in ['y', 'yes', 's', 'si']:
if not install_dependencies():
print()
print("❌ Failed to install dependencies!")
return 1
print()
print("✅ Dependencies installed successfully!")
print()
else:
print()
print("Please install dependencies manually:")
print(" pip install -r requirements-dev.txt")
return 1
# Parse custom arguments
pytest_args = []
if "--cov" in args:
pytest_args.extend([
"--cov=core",
"--cov-report=html",
"--cov-report=term-missing"
])
args.remove("--cov")
if "--verbose" in args:
pytest_args.append("-vv")
args.remove("--verbose")
if "--fast" in args:
pytest_args.extend(["-m", "not slow"])
args.remove("--fast")
# Add remaining arguments
pytest_args.extend(args)
# Run tests
print("=" * 70)
print("Running Flowfull-Python Client Tests")
print("=" * 70)
print()
exit_code = run_tests(pytest_args)
print()
print("=" * 70)
if exit_code == 0:
print("✅ All tests passed!")
else:
print("❌ Some tests failed!")
print("=" * 70)
return exit_code
if __name__ == "__main__":
sys.exit(main())