Skip to content

Commit

Permalink
Makes common/cfg.py raise AttributeError
Browse files Browse the repository at this point in the history
 * fixes bug 915039
 * includes test

Change-Id: I67b886be3b5af3763f52fffe54085975d61d61eb
  • Loading branch information
vishvananda committed Jan 11, 2012
1 parent 0bbf67c commit 4d01531
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nova/common/cfg.py
Expand Up @@ -229,7 +229,7 @@ def __str__(self):
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):
Expand Down
5 changes: 5 additions & 0 deletions nova/tests/test_cfg.py
Expand Up @@ -598,6 +598,11 @@ def test_unknown_attr(self):
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'))

Expand Down

0 comments on commit 4d01531

Please sign in to comment.