-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·43 lines (34 loc) · 1.14 KB
/
run.py
File metadata and controls
executable file
·43 lines (34 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
#!/usr/bin/env python3
import json
import subprocess
from pathlib import Path
import sys
def run_tests():
directory = Path(__file__).parent
config_file = directory / 'config.json'
try:
with open(config_file, 'r', encoding='utf-8') as json_file:
tests = json.load(json_file)
for test in tests:
print(f"\nRunning test: {test}")
result = subprocess.run(
[sys.executable, "-m", "unittest", test],
capture_output=True,
text=True
)
print(result.stdout)
if result.stderr:
print(f"Errors: {result.stderr}")
if result.returncode != 0:
print(f"Test {test} failed with return code {result.returncode}")
except FileNotFoundError:
print(f"Error: Configuration file not found at {config_file}")
sys.exit(1)
except json.JSONDecodeError:
print(f"Error: Invalid JSON in configuration file {config_file}")
sys.exit(1)
except Exception as e:
print(f"Error: {str(e)}")
sys.exit(1)
if __name__ == "__main__":
run_tests()