diff --git a/ChangeLog b/ChangeLog index 602e3cc..4ccc2f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ Sat Apr 18 22:42:53 2015 +0200 Emmanuel Garette Settings) to validate value with those object. Now value with callback and consistency are correctly validate * ability to disable warnings validation + * if ValueError and PropertieError together, should raise with + PropertieError Sun Mar 8 12:02:17 2015 +0200 Emmanuel Garette * valid default/callback value in consistencies diff --git a/test/test_option_calculation.py b/test/test_option_calculation.py index 979c759..6b12387 100644 --- a/test/test_option_calculation.py +++ b/test/test_option_calculation.py @@ -843,6 +843,20 @@ def test_callback_two_disabled2(): assert cfg.getowner(opt2, force_permissive=True) == owners.default +def test_callback_calculating_invalid(): + opt1 = IntOption('opt1', '', 1) + opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)}) + od1 = OptionDescription('od1', '', [opt1]) + od2 = OptionDescription('od2', '', [opt2]) + maconfig = OptionDescription('rootconfig', '', [od1, od2]) + cfg = Config(maconfig) + setting = cfg.cfgimpl_get_settings() + cfg.read_write() + raises(ValueError, 'cfg.od2.opt2') + setting[opt2].append('disabled') + raises(PropertiesOptionError, 'cfg.od2.opt2') + + def test_callback_calculating_disabled(): opt1 = BoolOption('opt1', '', properties=('disabled',)) opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)}) diff --git a/tiramisu/value.py b/tiramisu/value.py index eed993b..ae774b7 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -300,10 +300,15 @@ class Values(object): force_submulti_index = submulti_index if setting_properties is undefined: setting_properties = setting._getproperties() - opt.impl_validate(value, context, - 'validator' in setting_properties, - force_index=force_index, - force_submulti_index=force_submulti_index) + try: + opt.impl_validate(value, context, + 'validator' in setting_properties, + force_index=force_index, + force_submulti_index=force_submulti_index) + except ValueError, err: + config_error = err + value = None + #FIXME pas de test avec les metas ... #FIXME et les symlinkoption ... if is_default and 'force_store_value' in setting._getitem(opt,