diff --git a/oslo_config/generator.py b/oslo_config/generator.py index 52016be7..cfdecc83 100644 --- a/oslo_config/generator.py +++ b/oslo_config/generator.py @@ -186,7 +186,11 @@ class _OptFormatter(object): opt_type = self._TYPE_DESCRIPTIONS.get(type(opt), 'unknown type') - help_text = u'%s(%s)' % (opt.help + ' ' if opt.help else '', opt_type) + if opt.help: + help_text = u'%s (%s)' % (opt.help, + opt_type) + else: + help_text = u'(%s)' % opt_type lines = self._format_help(help_text) for d in opt.deprecated_opts: diff --git a/test-requirements.txt b/test-requirements.txt index e23d9ef8..7f76d34f 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -21,5 +21,8 @@ coverage>=3.6 sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3 oslosphinx>=2.2.0 # Apache-2.0 +# Required only for tests +oslo.i18n>=1.3.0 # Apache-2.0 + # mocking framework mock>=1.0 diff --git a/tests/test_generator.py b/tests/test_generator.py index 72c2b7e9..e4768672 100644 --- a/tests/test_generator.py +++ b/tests/test_generator.py @@ -23,6 +23,7 @@ import testscenarios from oslo.config import cfg from oslo.config import fixture as config_fixture from oslo.config import generator +from oslo.i18n import fixture as i18n_fixture load_tests = testscenarios.load_tests_apply_scenarios @@ -31,6 +32,9 @@ class GeneratorTestCase(base.BaseTestCase): opts = { 'foo': cfg.StrOpt('foo', help='foo option'), + 'foo_i18n_help': cfg.StrOpt('foo_i18n_help', + help=i18n_fixture.Translation().lazy( + 'this is a lazy message')), 'bar': cfg.StrOpt('bar', help='bar option'), 'foo-bar': cfg.StrOpt('foo-bar', help='foobar'), 'no_help': cfg.StrOpt('no_help'), @@ -206,6 +210,17 @@ class GeneratorTestCase(base.BaseTestCase): # foobar (string value) #foo_bar = +''')), + ('i18n_help', + dict(opts=[('test', [(None, [opts['foo_i18n_help']])])], + expected='''[DEFAULT] + +# +# From test +# + +# this is a lazy message (string value) +#foo_i18n_help = ''')), ('no_help', dict(opts=[('test', [(None, [opts['no_help']])])],