fix: do not cache subconfig in api
This commit is contained in:
parent
a18e089387
commit
a8cb8bce32
2 changed files with 29 additions and 2 deletions
|
|
@ -139,7 +139,7 @@ def test_mod_read_only_write():
|
|||
|
||||
|
||||
def test_setting_tree(config_type):
|
||||
s = StrOption("string", "", default=["string", "sdfsdf"], default_multi="prout", multi=True)
|
||||
s = StrOption("string", "", default=["string", "sdfsdf"], default_multi="value", multi=True)
|
||||
od4 = OptionDescription("option4", "", [s])
|
||||
od3 = OptionDescription("option3", "", [od4])
|
||||
od2 = OptionDescription("option2", "", [od3], properties=('hidden',))
|
||||
|
|
@ -151,8 +151,23 @@ def test_setting_tree(config_type):
|
|||
cfg.option('option2.option3.option4.string').value.get()
|
||||
|
||||
|
||||
def test_setting_tree_2(config_type):
|
||||
s = StrOption("string", "", default=["string", "sdfsdf"], default_multi="value", multi=True)
|
||||
od4 = OptionDescription("option4", "", [s])
|
||||
od3 = OptionDescription("option3", "", [od4])
|
||||
od2 = OptionDescription("option2", "", [od3], properties=('hidden',))
|
||||
od1 = OptionDescription("root", "", [od2])
|
||||
cfg = Config(od1)
|
||||
cfg = get_config(cfg, config_type)
|
||||
cfg.property.read_write()
|
||||
option = cfg.option('option2.option3.option4.string')
|
||||
option.isoptiondescription()
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
option.value.get()
|
||||
|
||||
|
||||
def test_setitem(config_type):
|
||||
s = StrOption("string", "", default=["string", "sdfsdf"], default_multi="prout", multi=True)
|
||||
s = StrOption("string", "", default=["string", "sdfsdf"], default_multi="value", multi=True)
|
||||
od1 = OptionDescription("options", "", [s])
|
||||
cfg = Config(od1)
|
||||
cfg = get_config(cfg, config_type)
|
||||
|
|
|
|||
|
|
@ -127,6 +127,18 @@ class CommonTiramisu(TiramisuHelp):
|
|||
|
||||
def _set_subconfig(self) -> None:
|
||||
if self._subconfig:
|
||||
if self._validate_properties:
|
||||
# FIXME: to force the properties validation, should be done only one time
|
||||
try:
|
||||
self._config_bag.context.get_sub_config(
|
||||
self._config_bag,
|
||||
self._path,
|
||||
self._index,
|
||||
validate_properties=self._validate_properties,
|
||||
allow_dynoption=True,
|
||||
)
|
||||
except AssertionError as err:
|
||||
raise ConfigError(str(err))
|
||||
if id(self._subconfig.config_bag) != id(self._config_bag):
|
||||
subconfig = self._subconfig
|
||||
self._subconfig = subconfig.__class__(option=subconfig.option,
|
||||
|
|
|
|||
Loading…
Reference in a new issue