Update run_tests.py
This commit is contained in:
parent
eece52600b
commit
896a9ff085
21
run_tests.py
21
run_tests.py
@ -12,6 +12,12 @@ class TermFormat:
|
||||
BOLD = "\033[1m"
|
||||
|
||||
|
||||
def print_header(header, width, padding):
|
||||
print(
|
||||
f"{TermFormat.BOLD}{'=' * (int(width / 3) + padding)}{header}{'=' * (int(width / 3) + padding)}{TermFormat.ENDC}"
|
||||
)
|
||||
|
||||
|
||||
test_dir = Path(__file__).parent / "test_files"
|
||||
hj_exec = Path(__file__).parent / "main"
|
||||
|
||||
@ -29,9 +35,20 @@ for vf in valid_files:
|
||||
if len(str(vf)) > name_width:
|
||||
name_width = len(str(vf))
|
||||
|
||||
|
||||
print_header("helloJSON TEST SUITE", name_width, 9)
|
||||
print()
|
||||
print_header("VALID FILES", name_width, 13)
|
||||
|
||||
for vf in valid_files:
|
||||
with open(vf, "r") as infile:
|
||||
original = json.load(infile)
|
||||
try:
|
||||
original = json.load(infile)
|
||||
except json.JSONDecodeError as e:
|
||||
print(
|
||||
f"\n{TermFormat.BOLD}{TermFormat.FAIL}ERROR:{TermFormat.ENDC} Failed to decode {str(vf)}\n{e.msg}"
|
||||
)
|
||||
continue
|
||||
|
||||
cmd = [hj_exec, vf]
|
||||
|
||||
@ -50,5 +67,5 @@ for vf in valid_files:
|
||||
match = original == parsed
|
||||
|
||||
print(
|
||||
f"{str(vf):{name_width + 3}} {TermFormat.BOLD}{TermFormat.OKGREEN if match else TermFormat.FAIL}{'PASSED' if match else 'FAILED'}{TermFormat.ENDC}"
|
||||
f"\n{str(vf):{name_width + 3}} {TermFormat.BOLD}{TermFormat.OKGREEN if match else TermFormat.FAIL}{'PASSED' if match else 'FAILED'}{TermFormat.ENDC}"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user