Commit 3ab523bb authored by Bogdan's avatar Bogdan

Implemented testing script

parent ad1ef89c
import os
import sys
import importlib.util
import pathlib
ROOT = pathlib.Path(__file__).parent.parent.absolute()
print("\nSearching for tests at the path: "+ str(ROOT))
count = 0
resultCodeList = []
for (dirname, dirs, files) in os.walk(ROOT):
#print("\n In dir: "+ str(dirname))
#I assume all the tests are placed in a folder named "tests"
if ("\\tests" in str(dirname)) and not("\\tests\\" in str(dirname)):
try:
os.chdir(os.path.normpath(dirname))
exit_val = os.system("py -m unittest discover")
resultCodeList.append(exit_val) #once per folder i.e if 3 tests are in a folder and crash, there will be just one exit val
except Exception as e:
print(e)
continue
"""
for f in files:
#print("\n Get Current Directory "+ os.getcwd())
count += 1
print("\n"+ str(count) +" Executing: "+ str(os.path.normpath(dirname+"\\"+f)))
os.system("py "+ f)
"""
firstError = -1
i = 0
while i < len(resultCodeList):
if resultCodeList[i] != 0:
print("\nA test failed with code: "+ resultCodeList[i])
if (firstError < 0):
firstError = i
i += 1
if(firstError<0): #no errors found
sys.exit(0)
else:
sys.exit(resultCodeList[firstError]) #return the error code of the first error
\ No newline at end of file
import unittest import unittest
import sys import sys
sys.path.insert(1, './') sys.path.insert(1, '../')
# python -m unittest discover -v tests # python -m unittest discover -v tests
from processing.clusterer import Clusterer from processing.clusterer import Clusterer
......
print("In test ABC, hello wooorld")
#test = 4/0
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment