-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
36 lines (23 loc) · 778 Bytes
/
run_tests.py
File metadata and controls
36 lines (23 loc) · 778 Bytes
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
import subprocess
import sys
def run_tests():
result = subprocess.run(['python', '-m', 'unittest'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
errors = result.stderr.decode('utf-8')
output = result.stdout.decode('utf-8')
lines = output.split("\n")
failed_lines = list(filter(has_failed, lines))
if len(failed_lines) > 0 or "FAILED" in errors:
print(output)
if "FAILED" in errors:
print(errors)
if len(failed_lines) > 0:
error_output = "\n".join(failed_lines)
print(error_output)
sys.exit(1)
success_output = "\n".join(lines)
print(success_output)
sys.exit(0)
def has_failed(line):
return "<FAILED::>" in line
if __name__ == "__main__":
run_tests()