cannot add unvalaible consistency for an option
This commit is contained in:
parent
8f950620f7
commit
471af4fd75
5 changed files with 1009 additions and 783 deletions
|
@ -20,6 +20,13 @@ def test_consistency():
|
|||
raises(ConfigError, "a.impl_add_consistency('not_equal', 'a')")
|
||||
|
||||
|
||||
def test_consistency_not_exists():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
raises(ConfigError, "a.impl_add_consistency('not_exists', b)")
|
||||
|
||||
|
||||
def test_consistency_warnings_only():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
|
|
|
@ -49,5 +49,4 @@ gettext.translation(APP_NAME, fallback=True)
|
|||
|
||||
t = gettext.translation(APP_NAME, fallback=True)
|
||||
|
||||
def _(msg):
|
||||
return t.gettext(msg)
|
||||
_ = t.gettext
|
||||
|
|
|
@ -147,7 +147,7 @@ class Base(StorageBase):
|
|||
self.impl_getname()))
|
||||
if self.impl_get_callback()[0] is not None:
|
||||
raise ConfigError(_("a callback is already set for option {0}, "
|
||||
"cannot set another one's".format(self.impl_getname())))
|
||||
"cannot set another one's").format(self.impl_getname()))
|
||||
self._validate_callback(callback, callback_params)
|
||||
if callback is not None:
|
||||
validate_callback(callback, callback_params, 'callback')
|
||||
|
@ -629,7 +629,7 @@ class Option(OnlyOption):
|
|||
:param params: extra params (only warnings_only are allowed)
|
||||
"""
|
||||
if self.impl_is_readonly(): # pragma: optional cover
|
||||
raise AttributeError(_("'{0}' ({1}) cannont add consistency, option is"
|
||||
raise AttributeError(_("'{0}' ({1}) cannot add consistency, option is"
|
||||
" read-only").format(
|
||||
self.__class__.__name__,
|
||||
self.impl_getname()))
|
||||
|
@ -658,6 +658,8 @@ class Option(OnlyOption):
|
|||
raise ConfigError(_('every options in consistency must be '
|
||||
'multi or none'))
|
||||
func = '_cons_{0}'.format(func)
|
||||
if func not in dir(self):
|
||||
raise ConfigError(_('consistency {0} not available for this option'))
|
||||
all_cons_opts = tuple([self] + list(other_opts))
|
||||
value = self.impl_getdefault()
|
||||
if value is not None:
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue