-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·50 lines (40 loc) · 1.17 KB
/
run_tests.py
File metadata and controls
executable file
·50 lines (40 loc) · 1.17 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
#!/usr/bin/env python3
"""
Test runner script with graceful interruption handling.
"""
import sys
import subprocess
import signal
import os
def signal_handler(signum, frame):
"""Handle interruption signals gracefully."""
print("\n\nInterrupted by user. Exiting gracefully...")
sys.exit(0)
def main():
"""Run tests with graceful interruption handling."""
# Set up signal handlers
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
# Build pytest command with quiet options
cmd = [
sys.executable, "-m", "pytest",
"--quiet",
"--tb=short",
"--disable-warnings",
"--maxfail=10",
"--durations=10"
]
# Add any additional arguments passed to the script
cmd.extend(sys.argv[1:])
try:
# Run pytest as a subprocess
result = subprocess.run(cmd, check=False)
sys.exit(result.returncode)
except KeyboardInterrupt:
print("\n\nInterrupted by user. Exiting gracefully...")
sys.exit(0)
except Exception as e:
print(f"Error running tests: {e}")
sys.exit(1)
if __name__ == "__main__":
main()