we have to access to option without restriction

This commit is contained in:
Emmanuel Garette 2019-07-06 08:36:13 +02:00
parent d3eef77c03
commit e73f3d1e47
3 changed files with 252 additions and 235 deletions

View file

@ -4,6 +4,7 @@ from os import listdir
from os.path import dirname, abspath, join, normpath, splitext, isfile
import sys
import warnings
import pytest
from tiramisu import OptionDescription, Config
from tiramisu.error import ValueWarning
@ -123,7 +124,31 @@ def add_property(expected, prop, prop_value):
return ordered_form
def test_jsons():
LISTDATA = list_data()
LISTDATA_MOD = []
idx = 0
while True:
idx += 1
list_files = list_data('.mod{}'.format(idx))
if not list_files:
break
LISTDATA_MOD.extend(list_files)
@pytest.fixture(params=LISTDATA)
def filename(request):
return request.param
@pytest.fixture(params=LISTDATA_MOD)
def filename_mod(request):
return request.param
def test_jsons(filename):
debug = False
# debug = True
datadir = datapath()
@ -137,8 +162,6 @@ def test_jsons():
for remote in ['minimum', 'none', 'all']:
if debug:
print(' ==> remotable', remote)
filenames = list_data()
for filename in filenames:
modulepath = splitext(filename)[0]
if debug:
print(" {} (remote: {}, clearable: {})".format(filename, remote, clearable))
@ -191,14 +214,12 @@ def test_jsons():
assert values == expected, "error in file {}".format(filename)
def test_jsons_subconfig():
def test_jsons_subconfig(filename):
debug = False
# debug = True
datadir = datapath()
if debug:
print()
filenames = list_data()
for filename in filenames:
modulepath = splitext(filename)[0]
if debug:
print(" ", filename)
@ -267,21 +288,15 @@ def test_jsons_subconfig():
assert values == expected, "error in file {}".format(filename)
def test_updates():
def test_updates(filename_mod):
debug = False
# debug = True
datadir = datapath()
idx = 0
while True:
idx += 1
list_files = list_data('.mod{}'.format(idx))
if not list_files:
break
for filename in list_files:
if debug:
print("test/data/" + filename)
print("test/data/" + filename_mod)
for issub in [False, True]:
modulepath = splitext(filename)[0]
idx = int(filename_mod[-1])
modulepath = splitext(filename_mod)[0]
mod = __import__(modulepath)
descr = mod.get_description()
if issub:
@ -354,7 +369,7 @@ def test_updates():
with open(join(datadir, modulepath + '.dict'), 'w') as fh:
dump(config.value.dict(), fh, indent=2)
else:
assert config.value.dict() == dico_ori, "clearable {}, remote: {}, filename: {}".format(clearable, remote, filename)
assert config.value.dict() == dico_ori, "clearable {}, remote: {}, filename: {}".format(clearable, remote, filename_mod)
if root is None:
suboption = config.option
else:

View file

@ -144,6 +144,7 @@ class _TiramisuOptionOptionDescription(CommonTiramisuOption):
"""Manage option"""
_allow_optiondescription = True
_follower_need_index = False
_validate_properties = False
def __init__(self,
name: str,
@ -652,6 +653,7 @@ def _registers(_registers: Dict[str, type],
class _TiramisuOption(CommonTiramisu):
"""Manage selected option"""
_validate_properties = False
_registers = {}
def __init__(self,
name: Optional[str],

View file

@ -470,8 +470,8 @@ class TiramisuDict:
self.add_help(schema[path],
childapi)
except Exception as err:
import traceback
traceback.print_exc()
# import traceback
# traceback.print_exc()
if not init:
raise err
error = err