8 data
= json
.load(sys
.stdin
)
15 with
open(testfile
) as testfh
:
17 for line
in iter(testfh
.readline
, ""):
19 line
= line
.rstrip("\r\n")
21 prefix_pos
= line
.index(prefix
)
24 check_expr
= line
[prefix_pos
+ len(prefix
) :]
28 result
= eval(check_expr
, {"data": data
})
31 exception
= traceback
.format_exc().splitlines()[-1]
33 if exception
is not None:
35 "{file}:{line:d}: check threw exception: {expr}\n"
36 "{file}:{line:d}: exception was: {exception}\n".format(
37 file=testfile
, line
=lineno
, expr
=check_expr
, exception
=exception
43 "{file}:{line:d}: check returned False: {expr}\n".format(
44 file=testfile
, line
=lineno
, expr
=check_expr
52 sys
.exit("{} checks failed".format(fails
))
54 sys
.stdout
.write("{} checks passed\n".format(passes
))