diff options
author | Thomas Herve <therve@redhat.com> | 2015-06-08 15:36:52 +0200 |
---|---|---|
committer | Thomas Herve <therve@redhat.com> | 2015-06-08 16:26:16 +0200 |
commit | 0c9113f68285f7b55ca01f0bbb5ce6cddada5023 (patch) | |
tree | 74e0071e4d3b35b03f5293667011154d081a05fe | |
parent | 02a86d2eefeda5144ea8c39657aed24b8b0c9a39 (diff) | |
download | oslo-config-1.12.1.tar.gz |
Fix sorting issue in python 31.12.1
Fix an error appear when trying to sort options when having many options
and many groups in python 3.4.
Change-Id: Iec7447e004f3708d92bd30aad94a17378fc25f31
Closes-Bug: #1463025
-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): |