Makes common/cfg.py raise AttributeError

* fixes bug 915039
 * includes test

Change-Id: I67b886be3b5af3763f52fffe54085975d61d61eb
This commit is contained in:
Vishvananda Ishaya
2012-01-11 13:22:36 -08:00
parent 0d650f8952
commit e59d232b9a
2 changed files with 6 additions and 1 deletions

View File

@@ -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):

View File

@@ -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'))