-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·145 lines (118 loc) · 3.53 KB
/
run_tests.py
File metadata and controls
executable file
·145 lines (118 loc) · 3.53 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env python3
"""
Test runner script for GAFreqTrade.
Provides convenient commands for running different test suites.
"""
import sys
import subprocess
import argparse
def run_command(cmd):
"""Run a command and return the exit code."""
print(f"\nRunning: {' '.join(cmd)}\n")
result = subprocess.run(cmd)
return result.returncode
def main():
parser = argparse.ArgumentParser(
description="GAFreqTrade Test Runner",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
python run_tests.py --all # Run all tests
python run_tests.py --unit # Run unit tests only
python run_tests.py --integration # Run integration tests only
python run_tests.py --fast # Run fast tests (skip slow)
python run_tests.py --coverage # Run with coverage report
python run_tests.py --module genetic_ops # Run specific module tests
"""
)
parser.add_argument(
'--all', '-a',
action='store_true',
help='Run all tests'
)
parser.add_argument(
'--unit', '-u',
action='store_true',
help='Run unit tests only'
)
parser.add_argument(
'--integration', '-i',
action='store_true',
help='Run integration tests only'
)
parser.add_argument(
'--fast', '-f',
action='store_true',
help='Run fast tests (exclude slow tests)'
)
parser.add_argument(
'--coverage', '-c',
action='store_true',
help='Run tests with coverage report'
)
parser.add_argument(
'--verbose', '-v',
action='store_true',
help='Verbose output'
)
parser.add_argument(
'--module', '-m',
type=str,
help='Run tests for specific module (e.g., genetic_ops, fitness)'
)
parser.add_argument(
'--marker',
type=str,
help='Run tests with specific marker (e.g., mock, slow)'
)
parser.add_argument(
'--html',
action='store_true',
help='Generate HTML coverage report'
)
args = parser.parse_args()
# Build pytest command
cmd = ['pytest']
# Add verbosity
if args.verbose:
cmd.append('-v')
# Add coverage options
if args.coverage or args.html:
cmd.extend([
'--cov=ga_core',
'--cov=evaluation',
'--cov=orchestration',
'--cov=storage',
'--cov=utils',
'--cov-report=term-missing'
])
if args.html:
cmd.append('--cov-report=html')
# Add test selection
if args.unit:
cmd.append('tests/unit/')
elif args.integration:
cmd.append('tests/integration/')
elif args.module:
cmd.append(f'tests/unit/test_{args.module}.py')
elif args.all or not any([args.unit, args.integration, args.fast, args.marker, args.module]):
cmd.append('tests/')
# Add markers
if args.fast:
cmd.extend(['-m', 'not slow'])
if args.marker:
cmd.extend(['-m', args.marker])
# Run the tests
exit_code = run_command(cmd)
# Print summary
print("\n" + "="*60)
if exit_code == 0:
print("✅ All tests passed!")
else:
print("❌ Some tests failed!")
print("="*60 + "\n")
if args.html:
print("📊 HTML coverage report generated in: htmlcov/index.html\n")
return exit_code
if __name__ == '__main__':
sys.exit(main())