Make error message more clear
This commit adjusts sentence about option name and group in error messages to make it more clear and friendly. TrivialFix Change-Id: I0f23e9e0ff0499509621c5ae7b1fc4573d6037a7
This commit is contained in:
parent
fbe660df29
commit
c11571933e
@ -419,7 +419,7 @@ class NoSuchOptError(Error, AttributeError):
|
||||
|
||||
def __str__(self):
|
||||
group_name = 'DEFAULT' if self.group is None else self.group.name
|
||||
return "no such option in group %s: %s" % (group_name, self.opt_name)
|
||||
return "no such option %s in group [%s]" % (self.opt_name, group_name)
|
||||
|
||||
|
||||
class NoSuchGroupError(Error):
|
||||
@ -429,7 +429,7 @@ class NoSuchGroupError(Error):
|
||||
self.group_name = group_name
|
||||
|
||||
def __str__(self):
|
||||
return "no such group: %s" % self.group_name
|
||||
return "no such group [%s]" % self.group_name
|
||||
|
||||
|
||||
class DuplicateOptError(Error):
|
||||
@ -450,11 +450,9 @@ class RequiredOptError(Error):
|
||||
self.group = group
|
||||
|
||||
def __str__(self):
|
||||
if self.group is None:
|
||||
return "value required for option: %s" % self.opt_name
|
||||
else:
|
||||
return "value required for option: %s.%s" % (self.group.name,
|
||||
self.opt_name)
|
||||
group_name = 'DEFAULT' if self.group is None else self.group.name
|
||||
return "value required for option %s in group [%s]" % (self.opt_name,
|
||||
group_name)
|
||||
|
||||
|
||||
class TemplateSubstitutionError(Error):
|
||||
|
@ -45,15 +45,15 @@ class ExceptionsTestCase(base.BaseTestCase):
|
||||
|
||||
def test_no_such_opt_error(self):
|
||||
msg = str(cfg.NoSuchOptError('foo'))
|
||||
self.assertEqual('no such option in group DEFAULT: foo', msg)
|
||||
self.assertEqual('no such option foo in group [DEFAULT]', msg)
|
||||
|
||||
def test_no_such_opt_error_with_group(self):
|
||||
msg = str(cfg.NoSuchOptError('foo', cfg.OptGroup('bar')))
|
||||
self.assertEqual('no such option in group bar: foo', msg)
|
||||
self.assertEqual('no such option foo in group [bar]', msg)
|
||||
|
||||
def test_no_such_group_error(self):
|
||||
msg = str(cfg.NoSuchGroupError('bar'))
|
||||
self.assertEqual('no such group: bar', msg)
|
||||
self.assertEqual('no such group [bar]', msg)
|
||||
|
||||
def test_duplicate_opt_error(self):
|
||||
msg = str(cfg.DuplicateOptError('foo'))
|
||||
@ -61,11 +61,12 @@ class ExceptionsTestCase(base.BaseTestCase):
|
||||
|
||||
def test_required_opt_error(self):
|
||||
msg = str(cfg.RequiredOptError('foo'))
|
||||
self.assertEqual('value required for option: foo', msg)
|
||||
self.assertEqual('value required for option foo in group [DEFAULT]',
|
||||
msg)
|
||||
|
||||
def test_required_opt_error_with_group(self):
|
||||
msg = str(cfg.RequiredOptError('foo', cfg.OptGroup('bar')))
|
||||
self.assertEqual('value required for option: bar.foo', msg)
|
||||
self.assertEqual('value required for option foo in group [bar]', msg)
|
||||
|
||||
def test_template_substitution_error(self):
|
||||
msg = str(cfg.TemplateSubstitutionError('foobar'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user