-
-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy path__init__.py
47 lines (34 loc) · 1.28 KB
/
__init__.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
41
42
43
44
45
46
47
import os, sys, importlib
import unittest
# def load_tests(loader, tests, pattern):
def load_tests(loader, tests):
# suite = unittest.TestSuite();
test_file = "compiler/passingTests.txt";
if ( os.path.isfile(test_file) == False ):
print("no test file in ", os.getcwd()+"/compiler");
# return suite;
return
test_fp = open(test_file, "r");
#print("opened file", test_file)
for test in test_fp.readlines():
module_name = test.strip().split(".")[0]
class_name = module_name + "Test"
module = importlib.import_module("."+module_name, package="compiler")
class_ = getattr(module, class_name)
tests.append(loader.loadTestsFromTestCase(class_))
test_fp.close()
return
# return suite;
def load_test(loader, test, tests):
test_file = "compiler/"+test
if ( os.path.isfile(test_file) == False ):
print("no test file in ", os.getcwd()+"/compiler");
# return suite;
return
print("running test", test.strip())
module_name = test.strip().split(".")[0]
class_name = module_name + "Test"
module = importlib.import_module("."+module_name, package="compiler")
class_ = getattr(module, class_name)
tests.append(loader.loadTestsFromTestCase(class_))
return