add parents method to MetaConfig

This commit is contained in:
Emmanuel Garette 2019-09-02 14:08:05 +02:00
parent 7c641961d3
commit 06ad839468
3 changed files with 10 additions and 2 deletions

View file

@ -45,6 +45,9 @@ def test_multi_parents_path_same():
assert metacfg2.config.path() == 'metacfg1.metacfg2'
assert metacfg3.config.path() == 'metacfg1.metacfg3'
assert cfg1.config.path() == 'metacfg1.metacfg3.metacfg1.metacfg2.cfg1'
metacfg1.option('od1.i1').value.set(1)
metacfg3.option('od1.i1').value.set(2)
assert cfg1.option('od1.i1').value.get() == 1
orideep = cfg1.config.deepcopy(metaconfig_prefix="test_", session_id='test_cfg1')
deep = orideep
while True:
@ -55,11 +58,11 @@ def test_multi_parents_path_same():
assert len(children) < 2
deep = children[0]
assert deep.config.path() == 'test_metacfg3.test_metacfg1.test_metacfg2.test_cfg1'
assert cfg1.option('od1.i1').value.get() == 1
del orideep
raises(ConfigError, "deep.config.path()")
def test_multi_parents_value():
metacfg1 = make_metaconfig()
cfg1 = metacfg1.config.new(type='config', session_id="cfg1")

View file

@ -45,4 +45,4 @@ allfuncs.extend(all_options)
del(all_options)
__all__ = tuple(allfuncs)
del(allfuncs)
__version__ = "3.0rc14"
__version__ = "3.0rc15"

View file

@ -1445,6 +1445,11 @@ class _TiramisuContextMixConfig(_TiramisuContextGroupConfig, _TiramisuContextCon
"""Add config from MetaConfig"""
self._config_bag.context.add_config(config)
def parents(self):
"""Get all parents of current config"""
for parent in self._config_bag.context.get_parents():
yield self._return_config(parent)
class _TiramisuContextMetaConfig(_TiramisuContextMixConfig):
"""Actions to MetaConfig"""