Update unittest to ignore disabled functions.

This commit is contained in:
iabdalkader 2020-11-25 19:55:12 +02:00
parent 70fcd764df
commit 25e7b4a2e2

View File

@ -13,14 +13,14 @@ if not (TEST_DIR in os.listdir("")):
print("") print("")
test_failed = False test_failed = False
def print_result(test, passed): def print_result(test, result):
s = "Unittest (%s)"%(test) s = "Unittest (%s)"%(test)
padding = "."*(60-len(s)) padding = "."*(60-len(s))
print(s + padding + ("PASSED" if passed == True else "FAILED")) print(s + padding + result)
for test in sorted(os.listdir(SCRIPT_DIR)): for test in sorted(os.listdir(SCRIPT_DIR)):
if test.endswith(".py"): if test.endswith(".py"):
test_passed = True test_result = "PASSED"
test_path = "/".join((SCRIPT_DIR, test)) test_path = "/".join((SCRIPT_DIR, test))
try: try:
exec(open(test_path).read()) exec(open(test_path).read())
@ -29,8 +29,8 @@ for test in sorted(os.listdir(SCRIPT_DIR)):
raise Exception() raise Exception()
except Exception as e: except Exception as e:
test_failed = True test_failed = True
test_passed = False test_result = "DISABLED" if "unavailable" in str(e) else "FAILED"
print_result(test, test_passed) print_result(test, test_result)
if test_failed: if test_failed:
print("\nSome tests have FAILED!!!\n\n") print("\nSome tests have FAILED!!!\n\n")