summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Brik <yuval@brik.org.il>2017-07-25 22:35:43 +0300
committerBen Nemec <openstack@nemebean.com>2018-06-04 16:49:27 +0000
commitc7dc66cfd2ea0729a138b335d0718bc510aa85e5 (patch)
tree833d305b09243b592959e398050684183b62aa43
parent63ec59ebe54a1d6b6d09c742084f476551cc6a33 (diff)
downloadoslo-config-ocata-em.tar.gz
Empty groupname will be 'DEFAULT' by defaultocata-em3.22.2
By default, if the groupname is None, set it to 'DEFAULT'. Seems like several libraries are exporting such groups, and it causes sorting the 'by_section.items()' list to fail. Closes-Bug: #1705245 Change-Id: I2001dc4894ff1e24c0eaed9ba71e3c5fba02ae36 (cherry picked from commit d7931f25738a435574cd2d7740c650c78d71fdc2) (cherry picked from commit 3f9f8d935003b2d35dbc5a915aa23e3bbf341f6e)
-rw-r--r--oslo_config/sphinxext.py4
-rw-r--r--oslo_config/tests/test_sphinxext.py6
2 files changed, 7 insertions, 3 deletions
diff --git a/oslo_config/sphinxext.py b/oslo_config/sphinxext.py
index 8439c07..8c2311e 100644
--- a/oslo_config/sphinxext.py
+++ b/oslo_config/sphinxext.py
@@ -205,6 +205,8 @@ def _format_option_help(app, namespaces, split_namespaces):
else:
group_name = group
group = None
+ if group_name is None:
+ group_name = 'DEFAULT'
lines = _format_group(
app=app,
namespace=namespace,
@@ -227,6 +229,8 @@ def _format_option_help(app, namespaces, split_namespaces):
else:
group_name = group
group = None
+ if group_name is None:
+ group_name = 'DEFAULT'
group_objs.setdefault(group_name, group)
by_section.setdefault(group_name, []).extend(group_opts)
for group_name, group_opts in sorted(by_section.items()):
diff --git a/oslo_config/tests/test_sphinxext.py b/oslo_config/tests/test_sphinxext.py
index 03e7cbb..2a20196 100644
--- a/oslo_config/tests/test_sphinxext.py
+++ b/oslo_config/tests/test_sphinxext.py
@@ -403,14 +403,14 @@ class FormatOptionHelpTest(base.BaseTestCase):
_format_group.assert_any_call(
app=None,
namespace='namespace1',
- group_name=None,
+ group_name='DEFAULT',
group_obj=None,
opt_list=['opt1'],
)
_format_group.assert_any_call(
app=None,
namespace='namespace2',
- group_name=None,
+ group_name='DEFAULT',
group_obj=None,
opt_list=['opt2'],
)
@@ -429,7 +429,7 @@ class FormatOptionHelpTest(base.BaseTestCase):
_format_group.assert_called_once_with(
app=None,
namespace=None,
- group_name=None,
+ group_name='DEFAULT',
group_obj=None,
opt_list=['opt1', 'opt2'],
)