diff options
-rw-r--r-- | oslo_config/cfg.py | 2 | ||||
-rw-r--r-- | oslo_config/tests/test_cfg.py | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/oslo_config/cfg.py b/oslo_config/cfg.py index 064a4b9..625c5c6 100644 --- a/oslo_config/cfg.py +++ b/oslo_config/cfg.py @@ -1595,7 +1595,7 @@ class _Namespace(argparse.Namespace): namespace = _Namespace(self._conf) namespace._parser._add_parsed_config_file(sections, normalized) - for opt, group in sorted(self._conf._all_cli_opts()): + for opt, group in self._conf._all_cli_opts(): group_name = group.name if group is not None else None try: value = opt._get_from_namespace(namespace, group_name) diff --git a/oslo_config/tests/test_cfg.py b/oslo_config/tests/test_cfg.py index f8b8e8e..9470dcc 100644 --- a/oslo_config/tests/test_cfg.py +++ b/oslo_config/tests/test_cfg.py @@ -1431,6 +1431,20 @@ class ConfigFileOptsTestCase(BaseTestCase): self.assertTrue(hasattr(self.conf, 'foo')) self.assertEqual(self.conf.foo, 'bar-%08x') + def test_conf_file_sorted_group(self): + # Create enough groups for the sorted problem to appear + for i in range(10): + group = cfg.OptGroup('group%s' % i, 'options') + self.conf.register_group(group) + self.conf.register_cli_opt(cfg.StrOpt('opt1'), group=group) + + paths = self.create_tempfiles( + [('test', '[group1]\nopt1 = foo\n[group2]\nopt2 = bar\n')]) + + self.conf(['--config-file', paths[0]]) + + self.assertEqual(self.conf.group1.opt1, 'foo') + class ConfigFileReloadTestCase(BaseTestCase): |