Implement OptGroup.__str__ for log messages
This log message has been around since change I6e28c25f04273f7def486fadd541babc8cf423cb. The OptGroup doesn't implement __str__ so the warning message isn't helpful. This change implements __str__ to return the group name so the warning message actually helps people. Change-Id: Ie6d218e7f6ea846b1f7d7f8452cc07f0be9e32a5 Closes-Bug: #1719032
This commit is contained in:
parent
e6749d3208
commit
0cce0be52a
@ -1829,6 +1829,9 @@ class OptGroup(object):
|
||||
"""Clear this group's option parsing state."""
|
||||
self._argparse_group = None
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class ParseError(iniparser.ParseError):
|
||||
def __init__(self, msg, lineno, line, filename):
|
||||
|
@ -2235,6 +2235,7 @@ class OptGroupsTestCase(BaseTestCase):
|
||||
self.assertTrue(hasattr(self.conf, 'blaa'))
|
||||
self.assertTrue(hasattr(self.conf.blaa, 'foo'))
|
||||
self.assertEqual('bar', self.conf.blaa.foo)
|
||||
self.assertEqual('blaa', str(blaa_group))
|
||||
|
||||
def test_autocreate_group_by_name(self):
|
||||
self.conf.register_cli_opt(cfg.StrOpt('foo'), group='blaa')
|
||||
|
Loading…
Reference in New Issue
Block a user