From 2e4fdbca030fb58aacac373b67f1aa6b5cb4020e Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Wed, 12 Oct 2016 22:17:04 +0200 Subject: [PATCH] transitive in apply_requires should only by apply if properties are same has testing action --- ChangeLog | 2 ++ test/test_requires.py | 25 +++++++++++++++++++++++++ tiramisu/setting.py | 9 ++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a76a26c..3c2e8af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ Wed Oct 12 21:55:53 2016 +0200 Emmanuel Garette * consistency is now check "not_equal" if one option has PropertiesOptionError + * transitive in apply_requires should only by apply if properties are + same has testing action Mon Oct 10 21:39:04 2016 +0200 Emmanuel Garette * consistency with default value for all values now works diff --git a/test/test_requires.py b/test/test_requires.py index 5395160..b428f28 100644 --- a/test/test_requires.py +++ b/test/test_requires.py @@ -349,6 +349,31 @@ def test_requires_not_transitive(): c.ip_address_service_web +def test_requires_not_transitive_not_same_action(): + a = BoolOption('activate_service', '', True) + b = BoolOption('activate_service_web', '', True, + requires=[{'option': a, 'expected': False, 'action': 'disabled'}]) + d = IPOption('ip_address_service_web', '', + requires=[{'option': b, 'expected': False, + 'action': 'hidden', 'transitive': False}]) + od = OptionDescription('service', '', [a, b, d]) + c = Config(od) + c.read_write() + c.activate_service + c.activate_service_web + c.ip_address_service_web + c.activate_service = False + # + props = [] + try: + c.activate_service_web + except PropertiesOptionError as err: + props = err.proptype + assert props == ['disabled'] + # + raises(RequirementError, "c.ip_address_service_web") + + def test_requires_None(): a = BoolOption('activate_service', '') b = IPOption('ip_address_service', '', diff --git a/tiramisu/setting.py b/tiramisu/setting.py index 04b5b3b..3427ee5 100644 --- a/tiramisu/setting.py +++ b/tiramisu/setting.py @@ -633,6 +633,7 @@ class Settings(object): else: calc_properties = set() context = self._getcontext() + all_properties = None for requires in opt.impl_getrequires(): for require in requires: option, expected, action, inverse, \ @@ -653,7 +654,13 @@ class Settings(object): if isinstance(value, Exception): if isinstance(value, PropertiesOptionError): if not transitive: - continue + if all_properties is None: + all_properties = [] + for requires in opt.impl_getrequires(): + for require in requires: + all_properties.append(require[2]) + if not set(value.proptype) - set(all_properties): + continue properties = value.proptype if same_action and action not in properties: # pragma: optional cover raise RequirementError(_("option '{0}' has "