diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-02-02 23:25:53 +0000 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2012-02-02 23:27:27 +0000 |
| commit | d383f78f8ca27eaf982d150fd8c955f8bd451690 (patch) | |
| tree | 161548022f15e27fb3b35a05b98960e42791b44e | |
| parent | 8441babf22a597de4a526ec11538cb0c6b503646 (diff) | |
Makes common/cfg.py raise AttributeError
* fixes bug 915039
* includes test
Change-Id: I67b886be3b5af3763f52fffe54085975d61d61eb
| -rw-r--r-- | openstack/common/cfg.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_cfg.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/openstack/common/cfg.py b/openstack/common/cfg.py index c8c6a52..34d5e6f 100644 --- a/openstack/common/cfg.py +++ b/openstack/common/cfg.py @@ -240,7 +240,7 @@ class ArgsAlreadyParsedError(Error): return ret -class NoSuchOptError(Error): +class NoSuchOptError(Error, AttributeError): """Raised if an opt which doesn't exist is referenced.""" def __init__(self, opt_name, group=None): diff --git a/tests/unit/test_cfg.py b/tests/unit/test_cfg.py index 7d2ad0d..c93f444 100644 --- a/tests/unit/test_cfg.py +++ b/tests/unit/test_cfg.py @@ -763,6 +763,11 @@ class SadPathTestCase(BaseTestCase): self.assertFalse(hasattr(self.conf, 'foo')) self.assertRaises(NoSuchOptError, getattr, self.conf, 'foo') + def test_unknown_attr_is_attr_error(self): + self.conf([]) + self.assertFalse(hasattr(self.conf, 'foo')) + self.assertRaises(AttributeError, getattr, self.conf, 'foo') + def test_unknown_group_attr(self): self.conf.register_group(OptGroup('blaa')) |
