tiramisu-api-python/test/test_json.py

37 lines
964 B
Python
Raw Normal View History

2019-02-14 21:25:00 +01:00
# -*- coding: utf-8 -*-
from json import loads
from os import listdir
from os.path import dirname, abspath, join, normpath, splitext
# import warnings
# from tiramisu.error import ValueWarning
from tiramisu_json_api import Config
# warnings.simplefilter("always", ValueWarning)
def list_data():
datadir = join(normpath(dirname(abspath(__file__))), 'data')
filenames = listdir(datadir)
filenames.sort()
for filename in filenames:
if filename.endswith('.json'):
yield join(datadir, filename)
def test_jsons():
debug = False
# debug = True
for filename in list_data():
if 'master' in filename:
continue
if debug:
print('test_jsons', filename)
with open(filename, 'r') as fh:
json = loads(fh.read())
#
config = Config(json)
with open(filename[:-4] + 'dict', 'r') as fh:
assert loads(fh.read()) == config.value.dict()