-
Notifications
You must be signed in to change notification settings - Fork 6
/
DRAGen_testcases.py
35 lines (29 loc) · 1.29 KB
/
DRAGen_testcases.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
import os
import sys
def run_test_cases(test_folder):
files = os.listdir(test_folder)
for file in files:
try:
#with open('output.txt', 'a') as output_file:
if file.endswith(".py"):
file_path = os.path.join(test_folder, file)
module_name = file[:-3]
test_module = __import__(f"Test_Cases.{module_name}", fromlist=[module_name])
#print("Test case", module_name, "successful.")
sys.stdout = open('output.txt','a')
#with open('output.txt', 'a') as output_file:
# with open('output.txt','a') as stdout_file:
# original_stdout = sys.stdout
#
# sys.stdout = stdout_file
# try:
# pass
# finally:
# sys.stdout = original_stdout
#print("Test case", module_name, "successful.")
except Exception as e:
print(f"An error occurred while running test case {module_name}:", e)
print("Test case", module_name, "failed.")
if __name__ == "__main__":
test_folder = "Test_Cases"
run_test_cases(test_folder)