diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2012-11-23 11:45:04 +0000 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2012-11-23 11:46:45 +0000 |
| commit | ceb4aa7fe9e05b762f451045c1b92a3d7b696eac (patch) | |
| tree | 020624d0819c81935ebe3b3930a40e380dd3d525 | |
| parent | b4c0767e5529eb5d58aed90643354dbee83efefe (diff) | |
| download | oslo-ceb4aa7fe9e05b762f451045c1b92a3d7b696eac.tar.gz oslo-ceb4aa7fe9e05b762f451045c1b92a3d7b696eac.tar.xz oslo-ceb4aa7fe9e05b762f451045c1b92a3d7b696eac.zip | |
Fix broken --help with CommonConfigOpts
Since we switched to argparse, the way help strings are interpolated
have changed and broken --help with the options registered by
CommonConfigOpts.
Fix and add a new test case which would catch the issue.
Change-Id: I10e42efe4721e22ff41d0efbf390c805ccb9a6a0
| -rw-r--r-- | openstack/common/cfg.py | 6 | ||||
| -rw-r--r-- | tests/unit/test_cfg.py | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/openstack/common/cfg.py b/openstack/common/cfg.py index e967c61..98d10b4 100644 --- a/openstack/common/cfg.py +++ b/openstack/common/cfg.py @@ -1652,12 +1652,12 @@ class CommonConfigOpts(ConfigOpts): metavar='FORMAT', help='A logging.Formatter log message format string which may ' 'use any of the available logging.LogRecord attributes. ' - 'Default: %default'), + 'Default: %(default)s'), StrOpt('log-date-format', default=DEFAULT_LOG_DATE_FORMAT, metavar='DATE_FORMAT', - help='Format string for %(asctime)s in log records. ' - 'Default: %default'), + help='Format string for %%(asctime)s in log records. ' + 'Default: %(default)s'), StrOpt('log-file', metavar='PATH', help='(Optional) Name of log file to output to. ' diff --git a/tests/unit/test_cfg.py b/tests/unit/test_cfg.py index 384a57a..ed9d98e 100644 --- a/tests/unit/test_cfg.py +++ b/tests/unit/test_cfg.py @@ -1528,6 +1528,15 @@ class CommonOptsTestCase(BaseTestCase): super(CommonOptsTestCase, self).setUp() self.conf = CommonConfigOpts() + def test_print_help(self): + f = StringIO.StringIO() + self.conf([]) + self.conf.print_help(file=f) + self.assertTrue('debug' in f.getvalue()) + self.assertTrue('verbose' in f.getvalue()) + self.assertTrue('log-config' in f.getvalue()) + self.assertTrue('log-format' in f.getvalue()) + def test_debug_verbose(self): self.conf(['--debug', '--verbose']) |
