-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
46 lines (35 loc) · 1.14 KB
/
Copy pathrun_tests.py
File metadata and controls
46 lines (35 loc) · 1.14 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
#!/usr/bin/env python3
"""
Quick test runner with summary statistics.
Usage: python run_tests.py [options]
"""
import subprocess
import sys
from pathlib import Path
def run_tests(verbose=False, coverage=False, specific=None):
"""Run pytest with various options."""
cmd = ["python", "-m", "pytest", "tests/"]
if verbose:
cmd.append("-v")
if coverage:
cmd.extend(["--cov=.", "--cov-report=term-missing"])
if specific:
cmd.append(specific)
print(f"Running: {' '.join(cmd)}\n")
result = subprocess.run(cmd)
return result.returncode
if __name__ == "__main__":
if len(sys.argv) > 1:
if "--coverage" in sys.argv:
exit_code = run_tests(verbose=True, coverage=True)
elif "--verbose" in sys.argv or "-v" in sys.argv:
exit_code = run_tests(verbose=True)
elif "--help" in sys.argv or "-h" in sys.argv:
print(__doc__)
exit_code = 0
else:
exit_code = run_tests(verbose=True)
else:
# Default: run all tests with summary
exit_code = run_tests(verbose=True)
sys.exit(exit_code)