-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
·57 lines (39 loc) · 1.12 KB
/
test.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
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
import json
import os
from py2j import parse_f
from termcolor import colored
def test(name: str, path: str):
"""
Run all test cases within a given directory. Test cases should end in
".yml" and their expected outputs should be in the same directory and end
in ".json"
"""
if not os.path.exists(path):
return
passed = 0
total = 0
print(f"-- SET: {name} --")
for yml in sorted([path+f for f in os.listdir(path) if f.endswith(".yml")]):
result = parse_f(yml)
with open(yml[:-4] + ".json", "r") as f:
expected = f.read()
if result != expected:
print(":: %s:" % colored("FAILED", "red"), yml.split("/")[-1][:-4])
print("-- EXPECTED --")
print(expected)
print("-- RESULT --")
print(result)
else:
print(":: %s:" % colored("PASSED", "green"), yml.split("/")[-1][:-4])
passed += 1
total += 1