37 lines
964 B
Python
37 lines
964 B
Python
|
# -*- 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()
|