add parents method to MetaConfig
This commit is contained in:
parent
7c641961d3
commit
06ad839468
|
@ -45,6 +45,9 @@ def test_multi_parents_path_same():
|
||||||
assert metacfg2.config.path() == 'metacfg1.metacfg2'
|
assert metacfg2.config.path() == 'metacfg1.metacfg2'
|
||||||
assert metacfg3.config.path() == 'metacfg1.metacfg3'
|
assert metacfg3.config.path() == 'metacfg1.metacfg3'
|
||||||
assert cfg1.config.path() == 'metacfg1.metacfg3.metacfg1.metacfg2.cfg1'
|
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')
|
orideep = cfg1.config.deepcopy(metaconfig_prefix="test_", session_id='test_cfg1')
|
||||||
deep = orideep
|
deep = orideep
|
||||||
while True:
|
while True:
|
||||||
|
@ -55,11 +58,11 @@ def test_multi_parents_path_same():
|
||||||
assert len(children) < 2
|
assert len(children) < 2
|
||||||
deep = children[0]
|
deep = children[0]
|
||||||
assert deep.config.path() == 'test_metacfg3.test_metacfg1.test_metacfg2.test_cfg1'
|
assert deep.config.path() == 'test_metacfg3.test_metacfg1.test_metacfg2.test_cfg1'
|
||||||
|
assert cfg1.option('od1.i1').value.get() == 1
|
||||||
del orideep
|
del orideep
|
||||||
raises(ConfigError, "deep.config.path()")
|
raises(ConfigError, "deep.config.path()")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_multi_parents_value():
|
def test_multi_parents_value():
|
||||||
metacfg1 = make_metaconfig()
|
metacfg1 = make_metaconfig()
|
||||||
cfg1 = metacfg1.config.new(type='config', session_id="cfg1")
|
cfg1 = metacfg1.config.new(type='config', session_id="cfg1")
|
||||||
|
|
|
@ -45,4 +45,4 @@ allfuncs.extend(all_options)
|
||||||
del(all_options)
|
del(all_options)
|
||||||
__all__ = tuple(allfuncs)
|
__all__ = tuple(allfuncs)
|
||||||
del(allfuncs)
|
del(allfuncs)
|
||||||
__version__ = "3.0rc14"
|
__version__ = "3.0rc15"
|
||||||
|
|
|
@ -1445,6 +1445,11 @@ class _TiramisuContextMixConfig(_TiramisuContextGroupConfig, _TiramisuContextCon
|
||||||
"""Add config from MetaConfig"""
|
"""Add config from MetaConfig"""
|
||||||
self._config_bag.context.add_config(config)
|
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):
|
class _TiramisuContextMetaConfig(_TiramisuContextMixConfig):
|
||||||
"""Actions to MetaConfig"""
|
"""Actions to MetaConfig"""
|
||||||
|
|
Loading…
Reference in New Issue