-
Notifications
You must be signed in to change notification settings - Fork 38
/
test_skeleton.py
37 lines (26 loc) · 1.08 KB
/
test_skeleton.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
37
from UnitTesting.create_test import create_test
def test_your_module():
module = 'your_module_location.your_module'
module_name = 'name_of_your_module'
function_and_global_dict = {'function_call': ['your global', 'your next global', 'your next next global', 'etc']}
create_test(module, module_name, function_and_global_dict)
# Ignore this -- it's to ensure bash functionality
if __name__ == '__main__':
import sys
if len(sys.argv) <= 3:
failed_functions = []
for fun in dir():
if fun[0:5] == 'test_':
print('\nTesting ' + str(fun) + '...\n')
try:
exec(fun + '()')
except SystemExit:
failed_functions.append(fun)
if failed_functions != []:
import sys, os
with open(os.path.join('UnitTesting', 'failed_tests.txt'), 'a') as file:
for function in failed_functions:
file.write(sys.argv[0] + ': ' + str(function) + '\n')
sys.exit(1)
else:
globals()[sys.argv[4]]()