add requires test
This commit is contained in:
@ -474,20 +474,23 @@ class Settings(object):
|
||||
"imbrication detected for option:"
|
||||
" '{0}' with requirement on: "
|
||||
"'{1}'").format(path, reqpath))
|
||||
if option.impl_is_multi():
|
||||
if index is None:
|
||||
# multi is allowed only for slaves
|
||||
# so do not calculated requires if no index
|
||||
continue
|
||||
if not option.impl_is_multi():
|
||||
idx = None
|
||||
is_indexed = False
|
||||
elif option.impl_is_master_slaves('slave'):
|
||||
idx = index
|
||||
is_indexed = False
|
||||
else:
|
||||
idx = None
|
||||
is_indexed = True
|
||||
sconfig_bag = config_bag.copy('nooption')
|
||||
sconfig_bag.option = option
|
||||
try:
|
||||
value = context.getattr(reqpath,
|
||||
idx,
|
||||
sconfig_bag)
|
||||
if is_indexed:
|
||||
value = value[index]
|
||||
except PropertiesOptionError as err:
|
||||
if not transitive:
|
||||
if all_properties is None:
|
||||
@ -508,7 +511,7 @@ class Settings(object):
|
||||
'').format(opt.impl_get_display_name(),
|
||||
option.impl_get_display_name(),
|
||||
prop_msg,
|
||||
display_list(properties)))
|
||||
display_list(list(properties))))
|
||||
orig_value = err
|
||||
# transitive action, force expected
|
||||
value = expected[0]
|
||||
@ -562,6 +565,19 @@ class Settings(object):
|
||||
"""
|
||||
if self._getcontext().cfgimpl_get_meta() is not None:
|
||||
raise ConfigError(_('cannot change property with metaconfig'))
|
||||
if path is not None and config_bag.option.impl_getrequires() is not None:
|
||||
not_allowed_props = properties & getattr(config_bag.option, '_calc_properties', static_set)
|
||||
if not_allowed_props:
|
||||
if len(not_allowed_props) == 1:
|
||||
prop_msg = _('property')
|
||||
calc_msg = _('this property is calculated')
|
||||
else:
|
||||
prop_msg = _('properties')
|
||||
calc_msg = _('those properties are calculated')
|
||||
raise ValueError(_('cannot set {} {} for option {} {}'
|
||||
'').format(prop_msg, display_list(list(not_allowed_props), add_quote=True),
|
||||
config_bag.option.impl_getname(),
|
||||
calc_msg))
|
||||
if config_bag is None:
|
||||
opt = None
|
||||
else:
|
||||
@ -590,9 +606,7 @@ class Settings(object):
|
||||
raise ConfigError(_('cannot add this property: "{0}"').format(
|
||||
' '.join(property_)))
|
||||
|
||||
props = self.getproperties(path,
|
||||
None,
|
||||
config_bag)
|
||||
props = config_bag.option.impl_getproperties()
|
||||
self.setproperties(path,
|
||||
props | {property_},
|
||||
config_bag,
|
||||
|
Reference in New Issue
Block a user