diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-01-11 13:22:36 -0800 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-01-11 13:22:36 -0800 |
| commit | 4d01531f91e4b20db2cb6ff738ee9af724ed2bf1 (patch) | |
| tree | 0a4c8aa10bb2341df92d9e524e70160edba594b8 | |
| parent | 0bbf67cf396dedfe05b1d9ae2d8fb0cefb5b2a8e (diff) | |
| download | nova-4d01531f91e4b20db2cb6ff738ee9af724ed2bf1.tar.gz nova-4d01531f91e4b20db2cb6ff738ee9af724ed2bf1.tar.xz nova-4d01531f91e4b20db2cb6ff738ee9af724ed2bf1.zip | |
Makes common/cfg.py raise AttributeError
* fixes bug 915039
* includes test
Change-Id: I67b886be3b5af3763f52fffe54085975d61d61eb
| -rw-r--r-- | nova/common/cfg.py | 2 | ||||
| -rw-r--r-- | nova/tests/test_cfg.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/nova/common/cfg.py b/nova/common/cfg.py index 54940e7d9..58d17d99f 100644 --- a/nova/common/cfg.py +++ b/nova/common/cfg.py @@ -229,7 +229,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/nova/tests/test_cfg.py b/nova/tests/test_cfg.py index b70b7838a..440b7acc7 100644 --- a/nova/tests/test_cfg.py +++ b/nova/tests/test_cfg.py @@ -598,6 +598,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')) |
