diff options
| -rw-r--r-- | openstack/common/cfg.py | 5 | ||||
| -rw-r--r-- | tests/unit/test_cfg.py | 8 |
2 files changed, 6 insertions, 7 deletions
diff --git a/openstack/common/cfg.py b/openstack/common/cfg.py index 109bc28..728ecdc 100644 --- a/openstack/common/cfg.py +++ b/openstack/common/cfg.py @@ -464,7 +464,7 @@ def _is_opt_registered(opts, opt): :raises: DuplicateOptError if a naming conflict is detected """ if opt.dest in opts: - if opts[opt.dest]['opt'] is not opt: + if opts[opt.dest]['opt'] != opt: raise DuplicateOptError(opt.name) return True else: @@ -527,6 +527,9 @@ class Opt(object): else: self.deprecated_name = None + def __ne__(self, another): + return vars(self) != vars(another) + def _get_from_config_parser(self, cparser, section): """Retrieves the option value from a MultiConfigParser object. diff --git a/tests/unit/test_cfg.py b/tests/unit/test_cfg.py index c72c18e..d6286d3 100644 --- a/tests/unit/test_cfg.py +++ b/tests/unit/test_cfg.py @@ -1220,18 +1220,14 @@ class SadPathTestCase(BaseTestCase): def test_ok_duplicate(self): opt = StrOpt('foo') self.conf.register_cli_opt(opt) - self.conf.register_cli_opt(opt) + opt2 = StrOpt('foo') + self.conf.register_cli_opt(opt2) self.conf([]) self.assertTrue(hasattr(self.conf, 'foo')) self.assertEquals(self.conf.foo, None) - def test_error_duplicate(self): - self.conf.register_cli_opt(StrOpt('foo')) - self.assertRaises(DuplicateOptError, - self.conf.register_cli_opt, StrOpt('foo')) - def test_error_duplicate_with_different_dest(self): self.conf.register_cli_opt(StrOpt('foo', dest='f')) self.conf.register_cli_opt(StrOpt('foo')) |
