From 100a0110cdcbdbb82ab469edd0a257bd22983391 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 17 Mar 2016 22:06:16 +0100 Subject: [PATCH] support callback with propertyerror in master for mandatory_warnings --- test/test_option_calculation.py | 13 +++++++++++++ tiramisu/option/masterslave.py | 8 +++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/test/test_option_calculation.py b/test/test_option_calculation.py index 021f6e4..64fba6a 100644 --- a/test/test_option_calculation.py +++ b/test/test_option_calculation.py @@ -452,6 +452,19 @@ def test_callback_master_and_slaves_master2(): assert cfg.val1.val2 == ['val2'] +def test_callback_master_and_slaves_master3(): + val1 = StrOption('val1', "", multi=True, properties=('mandatory', 'empty')) + val2 = StrOption('val2', "", multi=True, default_multi='val2', properties=('expert',)) + val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val2, False),)}) + val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params={'': ((val3, False),)}) + interface1 = OptionDescription('val1', '', [val1, val2, val3, val4]) + interface1.impl_set_group_type(groups.master) + maconfig = OptionDescription('rootconfig', '', [interface1]) + cfg = Config(maconfig) + cfg.read_write() + assert list(cfg.cfgimpl_get_values().mandatory_warnings()) == ['val1.val1'] + + def test_callback_master_and_slaves_master_list(): val1 = StrOption('val1', "", multi=True, callback=return_list) val2 = StrOption('val2', "", multi=True) diff --git a/tiramisu/option/masterslave.py b/tiramisu/option/masterslave.py index 603018b..edb798a 100644 --- a/tiramisu/option/masterslave.py +++ b/tiramisu/option/masterslave.py @@ -127,7 +127,7 @@ class MasterSlaves(object): force_permissive, validate_properties, slave_path, slave_value, self_properties, index, - returns_raise) + returns_raise, setting_properties) else: return self._getslave(values, opt, path, validate, force_permissive, trusted_cached_properties, @@ -136,13 +136,15 @@ class MasterSlaves(object): def _getmaster(self, values, opt, path, validate, force_permissive, validate_properties, c_slave_path, - c_slave_value, self_properties, index, returns_raise): + c_slave_value, self_properties, index, returns_raise, + setting_properties): value = values._get_cached_value(opt, path=path, validate=validate, force_permissive=force_permissive, validate_properties=validate_properties, self_properties=self_properties, from_masterslave=True, index=index, - returns_raise=True) + returns_raise=True, + setting_properties=setting_properties) if isinstance(value, Exception): return value if index is None and validate is True: