-
Notifications
You must be signed in to change notification settings - Fork 38
/
test_GRMHD.py
40 lines (29 loc) · 1.26 KB
/
test_GRMHD.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
38
39
40
from UnitTesting.create_test import create_test
def test_equations():
module = 'GRMHD.equations'
module_name = 'GRMHD'
function_and_global_dict = {'generate_everything_for_UnitTesting()':
['GRHDT4UU','GRFFET4UU','T4UU','T4UD',
'rho_star','tau_tilde','S_tildeD',
'rho_star_fluxU','tau_tilde_fluxU','S_tilde_fluxUD',
's_source_term','S_tilde_source_termD']}
create_test(module, module_name, function_and_global_dict)
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]]()