Makes common/cfg.py raise AttributeError
* fixes bug 915039 * includes test Change-Id: I67b886be3b5af3763f52fffe54085975d61d61eb
This commit is contained in:
@@ -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):
|
||||
|
@@ -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'))
|
||||
|
||||
|
Reference in New Issue
Block a user