correction on test test_multi.py
This commit is contained in:
parent
924ac4e597
commit
48e172a59a
|
@ -586,41 +586,49 @@ class Settings(object):
|
||||||
# validate properties
|
# validate properties
|
||||||
|
|
||||||
def validate_properties(self,
|
def validate_properties(self,
|
||||||
opt_or_descr,
|
opt,
|
||||||
path,
|
path,
|
||||||
setting_properties,
|
setting_properties,
|
||||||
index=None,
|
index=None,
|
||||||
force_permissive=False):
|
force_permissive=False):
|
||||||
"""
|
"""
|
||||||
validation upon the properties related to `opt_or_descr`
|
validation upon the properties related to `opt`
|
||||||
|
|
||||||
:param opt_or_descr: an option or an option description object
|
:param opt: an option or an option description object
|
||||||
:param force_permissive: behaves as if the permissive property
|
:param force_permissive: behaves as if the permissive property
|
||||||
was present
|
was present
|
||||||
"""
|
"""
|
||||||
# opt properties
|
# opt properties
|
||||||
properties = self.getproperties(opt_or_descr,
|
self_properties = self.getproperties(opt,
|
||||||
path,
|
path,
|
||||||
setting_properties=setting_properties,
|
setting_properties=setting_properties,
|
||||||
index=index)
|
index=index)
|
||||||
|
|
||||||
# calc properties
|
# calc properties
|
||||||
properties &= setting_properties - set(['frozen'])
|
properties = self_properties & setting_properties - set(['frozen'])
|
||||||
if not opt_or_descr.impl_is_optiondescription():
|
if not opt.impl_is_optiondescription():
|
||||||
#mandatory
|
#mandatory
|
||||||
if 'mandatory' in properties or 'empty' in properties:
|
if 'mandatory' in properties or 'empty' in properties:
|
||||||
value = 'pouet'
|
value = self._getcontext().cfgimpl_get_values().get_cached_value(opt,
|
||||||
if self.validate_mandatory(opt_or_descr,
|
path=path,
|
||||||
|
validate=False,
|
||||||
|
setting_properties=setting_properties,
|
||||||
|
self_properties=self_properties,
|
||||||
|
index=index)
|
||||||
|
if not self.validate_mandatory(opt,
|
||||||
index,
|
index,
|
||||||
value,
|
value,
|
||||||
setting_properties,
|
setting_properties,
|
||||||
properties):
|
properties):
|
||||||
properties += set(['mandatory']) - set(['empty'])
|
properties -= set(['mandatory'])
|
||||||
else:
|
else:
|
||||||
properties -= set(['mandatory', 'empty'])
|
properties |= set(['mandatory'])
|
||||||
|
properties -= set(['empty'])
|
||||||
opt_type = 'option'
|
opt_type = 'option'
|
||||||
else:
|
else:
|
||||||
opt_type = 'optiondescription'
|
opt_type = 'optiondescription'
|
||||||
|
|
||||||
|
|
||||||
# remove permissive properties
|
# remove permissive properties
|
||||||
if force_permissive is True and properties:
|
if force_permissive is True and properties:
|
||||||
# remove global permissive if need
|
# remove global permissive if need
|
||||||
|
@ -628,7 +636,7 @@ class Settings(object):
|
||||||
|
|
||||||
# at this point an option should not remain in properties
|
# at this point an option should not remain in properties
|
||||||
if properties != frozenset():
|
if properties != frozenset():
|
||||||
datas = {'opt': opt_or_descr,
|
datas = {'opt': opt,
|
||||||
'path': path,
|
'path': path,
|
||||||
'setting_properties': setting_properties,
|
'setting_properties': setting_properties,
|
||||||
'index': index,
|
'index': index,
|
||||||
|
|
|
@ -70,16 +70,7 @@ class Values(object):
|
||||||
self_properties=undefined,
|
self_properties=undefined,
|
||||||
index=None,
|
index=None,
|
||||||
display_warnings=True):
|
display_warnings=True):
|
||||||
context = self._getcontext()
|
|
||||||
settings = context.cfgimpl_get_settings()
|
|
||||||
if path is None:
|
|
||||||
path = opt.impl_getpath(context)
|
|
||||||
ntime = None
|
ntime = None
|
||||||
if self_properties is undefined:
|
|
||||||
self_properties = settings.getproperties(opt,
|
|
||||||
path,
|
|
||||||
setting_properties=setting_properties,
|
|
||||||
index=index)
|
|
||||||
if 'cache' in setting_properties and self._p_.hascache(path, index):
|
if 'cache' in setting_properties and self._p_.hascache(path, index):
|
||||||
if 'expire' in setting_properties:
|
if 'expire' in setting_properties:
|
||||||
ntime = int(time())
|
ntime = int(time())
|
||||||
|
@ -113,7 +104,7 @@ class Values(object):
|
||||||
path,
|
path,
|
||||||
validate,
|
validate,
|
||||||
setting_properties,
|
setting_properties,
|
||||||
self_properties=None,
|
self_properties=undefined,
|
||||||
index=None,
|
index=None,
|
||||||
display_warnings=True,
|
display_warnings=True,
|
||||||
force_permissive=False):
|
force_permissive=False):
|
||||||
|
@ -181,6 +172,12 @@ class Values(object):
|
||||||
:param opt: the `option.Option()` object
|
:param opt: the `option.Option()` object
|
||||||
:returns: the option's value (or the default value if not set)
|
:returns: the option's value (or the default value if not set)
|
||||||
"""
|
"""
|
||||||
|
if self_properties is undefined:
|
||||||
|
settings = self._getcontext().cfgimpl_get_settings()
|
||||||
|
self_properties = settings.getproperties(opt,
|
||||||
|
path,
|
||||||
|
setting_properties=setting_properties,
|
||||||
|
index=index)
|
||||||
force_default = 'frozen' in self_properties and \
|
force_default = 'frozen' in self_properties and \
|
||||||
'force_default_on_freeze' in self_properties
|
'force_default_on_freeze' in self_properties
|
||||||
# not default value
|
# not default value
|
||||||
|
@ -243,9 +240,13 @@ class Values(object):
|
||||||
context.cfgimpl_reset_cache(opt=opt,
|
context.cfgimpl_reset_cache(opt=opt,
|
||||||
path=path)
|
path=path)
|
||||||
|
|
||||||
|
if opt.impl_is_master_slaves('slave'):
|
||||||
|
index_ = index
|
||||||
|
else:
|
||||||
|
index_ = None
|
||||||
if self._is_meta(opt,
|
if self._is_meta(opt,
|
||||||
path,
|
path,
|
||||||
index,
|
index_,
|
||||||
setting_properties,
|
setting_properties,
|
||||||
force_permissive=force_permissive):
|
force_permissive=force_permissive):
|
||||||
meta = context.cfgimpl_get_meta()
|
meta = context.cfgimpl_get_meta()
|
||||||
|
@ -344,10 +345,7 @@ class Values(object):
|
||||||
else:
|
else:
|
||||||
allow_empty_list = opt.impl_allow_empty_list()
|
allow_empty_list = opt.impl_allow_empty_list()
|
||||||
if allow_empty_list is undefined:
|
if allow_empty_list is undefined:
|
||||||
if opt.impl_is_master_slaves('slave'):
|
allow_empty_list = opt.impl_is_master_slaves('slave')
|
||||||
allow_empty_list = True
|
|
||||||
else:
|
|
||||||
allow_empty_list = False
|
|
||||||
isempty = value is None or (not allow_empty_list and value == []) or \
|
isempty = value is None or (not allow_empty_list and value == []) or \
|
||||||
None in value or empty in value
|
None in value or empty in value
|
||||||
else:
|
else:
|
||||||
|
@ -744,7 +742,8 @@ class Values(object):
|
||||||
#______________________________________________________________________
|
#______________________________________________________________________
|
||||||
# mandatory warnings
|
# mandatory warnings
|
||||||
|
|
||||||
def mandatory_warnings(self, force_permissive=True):
|
def mandatory_warnings(self,
|
||||||
|
force_permissive=True):
|
||||||
"""convenience function to trace Options that are mandatory and
|
"""convenience function to trace Options that are mandatory and
|
||||||
where no value has been set
|
where no value has been set
|
||||||
|
|
||||||
|
@ -776,10 +775,14 @@ class Values(object):
|
||||||
|
|
||||||
if opt.impl_is_optiondescription():
|
if opt.impl_is_optiondescription():
|
||||||
#FIXME ?
|
#FIXME ?
|
||||||
if not settings.validate_properties(opt, True, False, path=path,
|
if not settings.validate_properties(opt,
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
path=path,
|
||||||
force_permissive=True,
|
force_permissive=True,
|
||||||
setting_properties=setting_properties):
|
setting_properties=setting_properties):
|
||||||
for path in _mandatory_warnings(opt, currpath + [name]):
|
for path in _mandatory_warnings(opt,
|
||||||
|
currpath + [name]):
|
||||||
yield path
|
yield path
|
||||||
else:
|
else:
|
||||||
if opt.impl_is_symlinkoption():
|
if opt.impl_is_symlinkoption():
|
||||||
|
@ -788,7 +791,8 @@ class Values(object):
|
||||||
path,
|
path,
|
||||||
setting_properties=setting_properties)
|
setting_properties=setting_properties)
|
||||||
if 'mandatory' in self_properties or 'empty' in self_properties:
|
if 'mandatory' in self_properties or 'empty' in self_properties:
|
||||||
err = self.get_cached_value(opt, path=path,
|
err = self.get_cached_value(opt,
|
||||||
|
path=path,
|
||||||
trusted_cached_properties=False,
|
trusted_cached_properties=False,
|
||||||
force_permissive=True,
|
force_permissive=True,
|
||||||
setting_properties=setting_properties,
|
setting_properties=setting_properties,
|
||||||
|
|
Loading…
Reference in New Issue