-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_tests.py
36 lines (27 loc) · 951 Bytes
/
run_tests.py
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 glob
import os
ignore = []
class cd:
"""Context manager for changing the current working directory"""
def __init__(self, new_path):
self.new_path = os.path.expanduser(new_path)
def __enter__(self):
self.savedPath = os.getcwd()
os.chdir(self.new_path)
def __exit__(self, etype, value, traceback):
os.chdir(self.savedPath)
if __name__ == "__main__":
files = [f for f in glob.glob("./tests/**/*.py")] + [f for f in glob.glob("./tests/*.py")]
for f in files:
if f in ignore:
continue
path, filename = os.path.split(f)
with cd(path):
print('Testing %s' % filename)
exitcode = os.system("python %s" % filename)
if exitcode != 0:
assert False, "Testing %s was not successful!" % f
else:
print("Testing %s was successful!" % filename)
print('Done tests')
exit(0)