From 06ad839468cf5bd5df14e3d184f8dd690571ffac Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 2 Sep 2019 14:08:05 +0200 Subject: [PATCH] add parents method to MetaConfig --- tests/test_multi_parents.py | 5 ++++- tiramisu/__init__.py | 2 +- tiramisu/api.py | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_multi_parents.py b/tests/test_multi_parents.py index 257c27b..da42c73 100644 --- a/tests/test_multi_parents.py +++ b/tests/test_multi_parents.py @@ -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") diff --git a/tiramisu/__init__.py b/tiramisu/__init__.py index 10b3933..c9f19cf 100644 --- a/tiramisu/__init__.py +++ b/tiramisu/__init__.py @@ -45,4 +45,4 @@ allfuncs.extend(all_options) del(all_options) __all__ = tuple(allfuncs) del(allfuncs) -__version__ = "3.0rc14" +__version__ = "3.0rc15" diff --git a/tiramisu/api.py b/tiramisu/api.py index 1b626e8..e98fcbb 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -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"""