better error messages with list
This commit is contained in:
parent
1aec891408
commit
63094f7e54
9 changed files with 45 additions and 48 deletions
|
@ -99,12 +99,12 @@ def test_consistency_error_prefix():
|
||||||
try:
|
try:
|
||||||
api.option('b').value.set(1)
|
api.option('b').value.set(1)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
assert str(err) == _('"{0}" is an invalid {1} for "{2}"').format('1', _('integer'), 'b') + ', ' + _('must be different from the value of "{}"').format('a')
|
assert str(err) == _('"{0}" is an invalid {1} for "{2}"').format('1', _('integer'), 'b') + ', ' + _('must be different from the value of {}').format('"a"')
|
||||||
try:
|
try:
|
||||||
api.option('b').value.set(1)
|
api.option('b').value.set(1)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
err.prefix = ''
|
err.prefix = ''
|
||||||
assert str(err) == _('must be different from the value of "{}"').format('a')
|
assert str(err) == _('must be different from the value of {}').format('"a"')
|
||||||
|
|
||||||
|
|
||||||
def test_consistency_warnings_only_option():
|
def test_consistency_warnings_only_option():
|
||||||
|
|
|
@ -621,9 +621,9 @@ def test_pprint():
|
||||||
except PropertiesOptionError as error:
|
except PropertiesOptionError as error:
|
||||||
err = error
|
err = error
|
||||||
|
|
||||||
list_disabled = '"disabled" (' + display_list([msg_is.format('Test int option', '"1"'), msg_is.format('string2', '"string"')]) + ')'
|
list_disabled = '"disabled" (' + display_list([msg_is.format('Test int option', '"1"'), msg_is.format('string2', '"string"')], add_quote=False) + ')'
|
||||||
list_hidden = '"hidden" (' + msg_is_not.format('Test int option', display_list([2, 3, 4], 'or', add_quote=True)) + ')'
|
list_hidden = '"hidden" (' + msg_is_not.format('Test int option', display_list([2, 3, 4], 'or', add_quote=True)) + ')'
|
||||||
assert str(err) == _(msg_error.format('option', 'Test string option', properties, display_list([list_disabled, list_hidden])))
|
assert str(err) == _(msg_error.format('option', 'Test string option', properties, display_list([list_disabled, list_hidden], add_quote=False)))
|
||||||
del err
|
del err
|
||||||
|
|
||||||
err = None
|
err = None
|
||||||
|
|
|
@ -45,4 +45,4 @@ allfuncs.extend(all_options)
|
||||||
del(all_options)
|
del(all_options)
|
||||||
__all__ = tuple(allfuncs)
|
__all__ = tuple(allfuncs)
|
||||||
del(allfuncs)
|
del(allfuncs)
|
||||||
__version__ = "3.0rc5"
|
__version__ = "3.0rc6"
|
||||||
|
|
|
@ -94,8 +94,8 @@ class PropertiesOptionError(AttributeError):
|
||||||
only_one = len(req) == 1
|
only_one = len(req) == 1
|
||||||
msg = []
|
msg = []
|
||||||
for action, msg_ in req.items():
|
for action, msg_ in req.items():
|
||||||
msg.append('"{0}" ({1})'.format(action, display_list(msg_)))
|
msg.append('"{0}" ({1})'.format(action, display_list(msg_, add_quote=False)))
|
||||||
msg = display_list(msg)
|
msg = display_list(msg, add_quote=False)
|
||||||
else:
|
else:
|
||||||
only_one = len(self.proptype) == 1
|
only_one = len(self.proptype) == 1
|
||||||
msg = display_list(list(self.proptype), add_quote=True)
|
msg = display_list(list(self.proptype), add_quote=True)
|
||||||
|
|
|
@ -2,7 +2,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Tiramisu\n"
|
"Project-Id-Version: Tiramisu\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2019-04-08 08:41+CEST\n"
|
"POT-Creation-Date: 2019-04-13 21:34+CEST\n"
|
||||||
"PO-Revision-Date: \n"
|
"PO-Revision-Date: \n"
|
||||||
"Last-Translator: Emmanuel Garette <egarette@cadoles.com>\n"
|
"Last-Translator: Emmanuel Garette <egarette@cadoles.com>\n"
|
||||||
"Language-Team: Tiramisu's team <egarette@cadoles.com>\n"
|
"Language-Team: Tiramisu's team <egarette@cadoles.com>\n"
|
||||||
|
@ -247,49 +247,46 @@ msgstr ""
|
||||||
"toutes les configs d'une metaconfig doivent avoir la même optiondescription"
|
"toutes les configs d'une metaconfig doivent avoir la même optiondescription"
|
||||||
|
|
||||||
#: tiramisu/config.py:1272
|
#: tiramisu/config.py:1272
|
||||||
#, fuzzy
|
|
||||||
#| msgid "all config in metaconfig must have the same optiondescription"
|
|
||||||
msgid "metaconfig must have the same optiondescription"
|
msgid "metaconfig must have the same optiondescription"
|
||||||
msgstr ""
|
msgstr "metaconfig doivent avoir la même optiondescription"
|
||||||
"toutes les configs d'une metaconfig doivent avoir la même optiondescription"
|
|
||||||
|
|
||||||
#: tiramisu/error.py:24
|
#: tiramisu/error.py:26
|
||||||
msgid "and"
|
msgid "and"
|
||||||
msgstr "et"
|
msgstr "et"
|
||||||
|
|
||||||
#: tiramisu/error.py:26
|
#: tiramisu/error.py:28
|
||||||
msgid "or"
|
msgid "or"
|
||||||
msgstr "ou"
|
msgstr "ou"
|
||||||
|
|
||||||
#: tiramisu/error.py:50
|
#: tiramisu/error.py:52
|
||||||
msgid " {} "
|
msgid " {} "
|
||||||
msgstr " {} "
|
msgstr " {} "
|
||||||
|
|
||||||
#: tiramisu/error.py:103 tiramisu/setting.py:579
|
#: tiramisu/error.py:105 tiramisu/setting.py:579
|
||||||
msgid "property"
|
msgid "property"
|
||||||
msgstr "de la propriété"
|
msgstr "de la propriété"
|
||||||
|
|
||||||
#: tiramisu/error.py:105 tiramisu/setting.py:581
|
#: tiramisu/error.py:107 tiramisu/setting.py:581
|
||||||
msgid "properties"
|
msgid "properties"
|
||||||
msgstr "des propriétés"
|
msgstr "des propriétés"
|
||||||
|
|
||||||
#: tiramisu/error.py:107
|
#: tiramisu/error.py:109
|
||||||
msgid "cannot access to {0} \"{1}\" because \"{2}\" has {3} {4}"
|
msgid "cannot access to {0} \"{1}\" because \"{2}\" has {3} {4}"
|
||||||
msgstr "ne peut accéder à {0} \"{1}\" parce que \"{2}\" a {3} {4}"
|
msgstr "ne peut accéder à {0} \"{1}\" parce que \"{2}\" a {3} {4}"
|
||||||
|
|
||||||
#: tiramisu/error.py:114
|
#: tiramisu/error.py:116
|
||||||
msgid "cannot access to {0} \"{1}\" because has {2} {3}"
|
msgid "cannot access to {0} \"{1}\" because has {2} {3}"
|
||||||
msgstr "ne peut accéder à l'{0} \"{1}\" a cause {2} {3}"
|
msgstr "ne peut accéder à l'{0} \"{1}\" a cause {2} {3}"
|
||||||
|
|
||||||
#: tiramisu/error.py:189
|
#: tiramisu/error.py:191
|
||||||
msgid "invalid value"
|
msgid "invalid value"
|
||||||
msgstr "valeur invalide"
|
msgstr "valeur invalide"
|
||||||
|
|
||||||
#: tiramisu/error.py:194
|
#: tiramisu/error.py:196
|
||||||
msgid "attention, \"{0}\" could be an invalid {1} for \"{2}\""
|
msgid "attention, \"{0}\" could be an invalid {1} for \"{2}\""
|
||||||
msgstr "attention, \"{0}\" peut être un {1} invalide pour \"{2}\""
|
msgstr "attention, \"{0}\" peut être un {1} invalide pour \"{2}\""
|
||||||
|
|
||||||
#: tiramisu/error.py:198 tiramisu/error.py:202
|
#: tiramisu/error.py:200 tiramisu/error.py:204
|
||||||
msgid "\"{0}\" is an invalid {1} for \"{2}\""
|
msgid "\"{0}\" is an invalid {1} for \"{2}\""
|
||||||
msgstr "\"{0}\" est une valeur invalide pour l'option \"{2}\" de type {1}"
|
msgstr "\"{0}\" est une valeur invalide pour l'option \"{2}\" de type {1}"
|
||||||
|
|
||||||
|
@ -490,8 +487,8 @@ msgid "only \"{0}\" is allowed"
|
||||||
msgstr "seul \"{0}\" est autorisé"
|
msgstr "seul \"{0}\" est autorisé"
|
||||||
|
|
||||||
#: tiramisu/option/choiceoption.py:117
|
#: tiramisu/option/choiceoption.py:117
|
||||||
msgid "only \"{0}\" are allowed"
|
msgid "only {0} are allowed"
|
||||||
msgstr "seul \"{0}\" sont autorisés"
|
msgstr "seul {0} sont autorisés"
|
||||||
|
|
||||||
#: tiramisu/option/dateoption.py:31
|
#: tiramisu/option/dateoption.py:31
|
||||||
msgid "date"
|
msgid "date"
|
||||||
|
@ -824,12 +821,12 @@ msgstr ""
|
||||||
"devrait être \"{}\""
|
"devrait être \"{}\""
|
||||||
|
|
||||||
#: tiramisu/option/option.py:716
|
#: tiramisu/option/option.py:716
|
||||||
msgid "should be different from the value of \"{}\""
|
msgid "should be different from the value of {}"
|
||||||
msgstr "devrait être différent de la valeur de \"{}\""
|
msgstr "devrait être différent de la valeur de {}"
|
||||||
|
|
||||||
#: tiramisu/option/option.py:718
|
#: tiramisu/option/option.py:718
|
||||||
msgid "must be different from the value of \"{}\""
|
msgid "must be different from the value of {}"
|
||||||
msgstr "doit être différent de la valeur de \"{}\""
|
msgstr "doit être différent de la valeur de {}"
|
||||||
|
|
||||||
#: tiramisu/option/option.py:721
|
#: tiramisu/option/option.py:721
|
||||||
msgid "value for {} should be different"
|
msgid "value for {} should be different"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"POT-Creation-Date: 2019-04-08 08:41+CEST\n"
|
"POT-Creation-Date: 2019-04-13 21:34+CEST\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -223,43 +223,43 @@ msgstr ""
|
||||||
msgid "metaconfig must have the same optiondescription"
|
msgid "metaconfig must have the same optiondescription"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/error.py:24
|
#: tiramisu/error.py:26
|
||||||
msgid "and"
|
msgid "and"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/error.py:26
|
#: tiramisu/error.py:28
|
||||||
msgid "or"
|
msgid "or"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/error.py:50
|
#: tiramisu/error.py:52
|
||||||
msgid " {} "
|
msgid " {} "
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/error.py:103 tiramisu/setting.py:579
|
#: tiramisu/error.py:105 tiramisu/setting.py:579
|
||||||
msgid "property"
|
msgid "property"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/error.py:105 tiramisu/setting.py:581
|
#: tiramisu/error.py:107 tiramisu/setting.py:581
|
||||||
msgid "properties"
|
msgid "properties"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/error.py:107
|
#: tiramisu/error.py:109
|
||||||
msgid "cannot access to {0} \"{1}\" because \"{2}\" has {3} {4}"
|
msgid "cannot access to {0} \"{1}\" because \"{2}\" has {3} {4}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/error.py:114
|
#: tiramisu/error.py:116
|
||||||
msgid "cannot access to {0} \"{1}\" because has {2} {3}"
|
msgid "cannot access to {0} \"{1}\" because has {2} {3}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/error.py:189
|
#: tiramisu/error.py:191
|
||||||
msgid "invalid value"
|
msgid "invalid value"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/error.py:194
|
#: tiramisu/error.py:196
|
||||||
msgid "attention, \"{0}\" could be an invalid {1} for \"{2}\""
|
msgid "attention, \"{0}\" could be an invalid {1} for \"{2}\""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/error.py:198 tiramisu/error.py:202
|
#: tiramisu/error.py:200 tiramisu/error.py:204
|
||||||
msgid "\"{0}\" is an invalid {1} for \"{2}\""
|
msgid "\"{0}\" is an invalid {1} for \"{2}\""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ msgid "only \"{0}\" is allowed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/option/choiceoption.py:117
|
#: tiramisu/option/choiceoption.py:117
|
||||||
msgid "only \"{0}\" are allowed"
|
msgid "only {0} are allowed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/option/dateoption.py:31
|
#: tiramisu/option/dateoption.py:31
|
||||||
|
@ -729,11 +729,11 @@ msgid "unexpected length of \"{}\" in constency \"{}\", should be \"{}\""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/option/option.py:716
|
#: tiramisu/option/option.py:716
|
||||||
msgid "should be different from the value of \"{}\""
|
msgid "should be different from the value of {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/option/option.py:718
|
#: tiramisu/option/option.py:718
|
||||||
msgid "must be different from the value of \"{}\""
|
msgid "must be different from the value of {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: tiramisu/option/option.py:721
|
#: tiramisu/option/option.py:721
|
||||||
|
|
|
@ -113,7 +113,7 @@ class Base:
|
||||||
set_forbidden_properties = calc_properties & properties
|
set_forbidden_properties = calc_properties & properties
|
||||||
if set_forbidden_properties != frozenset():
|
if set_forbidden_properties != frozenset():
|
||||||
raise ValueError(_('conflict: properties already set in requirement {0} for {1}'
|
raise ValueError(_('conflict: properties already set in requirement {0} for {1}'
|
||||||
'').format(display_list(set_forbidden_properties),
|
'').format(display_list(set_forbidden_properties, add_quote=True),
|
||||||
name))
|
name))
|
||||||
|
|
||||||
def _get_function_args(self,
|
def _get_function_args(self,
|
||||||
|
|
|
@ -114,5 +114,5 @@ class ChoiceOption(Option):
|
||||||
raise ValueError(_('only "{0}" is allowed'
|
raise ValueError(_('only "{0}" is allowed'
|
||||||
'').format(values[0]))
|
'').format(values[0]))
|
||||||
else:
|
else:
|
||||||
raise ValueError(_('only "{0}" are allowed'
|
raise ValueError(_('only {0} are allowed'
|
||||||
'').format(display_list(values)))
|
'').format(display_list(values, add_quote=True)))
|
||||||
|
|
|
@ -713,9 +713,9 @@ class Option(BaseOption):
|
||||||
if equal:
|
if equal:
|
||||||
if is_current:
|
if is_current:
|
||||||
if warnings_only:
|
if warnings_only:
|
||||||
msg = _('should be different from the value of "{}"')
|
msg = _('should be different from the value of {}')
|
||||||
else:
|
else:
|
||||||
msg = _('must be different from the value of "{}"')
|
msg = _('must be different from the value of {}')
|
||||||
else:
|
else:
|
||||||
if warnings_only:
|
if warnings_only:
|
||||||
msg = _('value for {} should be different')
|
msg = _('value for {} should be different')
|
||||||
|
@ -724,7 +724,7 @@ class Option(BaseOption):
|
||||||
equal_name = []
|
equal_name = []
|
||||||
for opt in equal:
|
for opt in equal:
|
||||||
equal_name.append(opt.impl_get_display_name())
|
equal_name.append(opt.impl_get_display_name())
|
||||||
raise ValueError(msg.format(display_list(list(equal_name))))
|
raise ValueError(msg.format(display_list(list(equal_name), add_quote=True)))
|
||||||
|
|
||||||
def to_dynoption(self,
|
def to_dynoption(self,
|
||||||
rootpath: str,
|
rootpath: str,
|
||||||
|
|
Loading…
Reference in a new issue