Skip to content

Commit aa706f4

Browse files
committed
tests: make validate schema return all failing validations
1 parent de51540 commit aa706f4

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

tests/validate_schema.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,29 @@
55
import json
66
import os
77
import progressbar
8+
import sys
89

9-
from jsonschema import validate
10+
from jsonschema import validate, ValidationError
1011

1112
with open("../game-schema-d4.json") as f:
1213
schema = json.load(f)
1314

1415
path = "../entries/"
1516
games_list = os.listdir(path)
1617
n = 0
17-
18+
errors = 0
1819

1920
for game in progressbar.progressbar(games_list, redirect_stdout=True):
2021
n += 1
2122
print(f"Validating {game}..")
2223
with open(f"../entries/{game}/game.json") as f:
23-
game = json.load(f)
24-
validate(game, schema)
24+
game_metadata = json.load(f)
25+
try:
26+
validate(game_metadata, schema)
27+
except ValidationError as e:
28+
errors += 1
29+
print(f"Failed {game}: \n {e}")
30+
31+
if errors > 0:
32+
print(f"\n {errors} entrie(s) have failed validation")
33+
sys.exit(1)

0 commit comments

Comments
 (0)