Enable nova exception format checking in tests.

Updates the Nova test runner so that it enables
'fatal_exception_format_errors' for testing.

Fixes a slew of issues in the tests including:
 -adds a whole bunch of missing kwarg's to exception constructors
 -removing an extra print statement in ec2/test_cloud
  (this was causing failures...)
 -removing a duplicate (and misnamed) flavor test case:
    test_remove_tenant_access_with_bad_access
 -removing an odd test case which tested throwing an exception with
  and without kwargs explicitly (the part testing without kwargs was
  removed)
 -explicitly update test/test_misc.py's test_exceptions_raise to disable
  formatting checks for now. This allows it to continue to pass.

Change-Id: Ibb5083c93f1a5de6edadb1b613292ff9eb26ddf0
This commit is contained in:
Dan Prince
2012-12-18 10:08:37 -05:00
parent 976c9937a1
commit f8a238cdee
3 changed files with 9 additions and 4 deletions

View File

@@ -222,6 +222,7 @@ class TestCase(testtools.TestCase):
self.addCleanup(self._clear_attrs)
self.useFixture(fixtures.EnvironmentVariable('http_proxy'))
self.policy = self.useFixture(policy_fixture.PolicyFixture())
CONF.set_override('fatal_exception_format_errors', True)
def _clear_attrs(self):
# Delete attributes that don't start with _ so they don't pin

View File

@@ -2054,7 +2054,9 @@ class LibvirtConnTestCase(test.TestCase):
self.mox.StubOutWithMock(conn, '_compare_cpu')
conn._compare_cpu("asdf").AndRaise(exception.InvalidCPUInfo)
conn._compare_cpu("asdf").AndRaise(exception.InvalidCPUInfo(
reason='foo')
)
self.mox.ReplayAll()
self.assertRaises(exception.InvalidCPUInfo,
@@ -2614,7 +2616,7 @@ class LibvirtConnTestCase(test.TestCase):
def test_immediate_delete(self):
def fake_lookup_by_name(instance_name):
raise exception.InstanceNotFound()
raise exception.InstanceNotFound(instance_id=instance_name)
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.stubs.Set(conn, '_lookup_by_name', fake_lookup_by_name)
@@ -2717,7 +2719,7 @@ class LibvirtConnTestCase(test.TestCase):
return mock
def fake_get_info(instance_name):
raise exception.InstanceNotFound()
raise exception.InstanceNotFound(instance_id=instance_name)
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.stubs.Set(conn, '_lookup_by_name', fake_lookup_by_name)
@@ -2736,7 +2738,7 @@ class LibvirtConnTestCase(test.TestCase):
self.stubs.Set(conn, 'list_instances', list_instances)
def get_info(instance_name):
raise exception.InstanceNotFound()
raise exception.InstanceNotFound(instance_id='fake')
self.stubs.Set(conn, 'get_instance_disk_info', get_info)
result = conn.get_disk_available_least()

View File

@@ -32,6 +32,8 @@ class ExceptionTestCase(test.TestCase):
raise exc()
def test_exceptions_raise(self):
# NOTE(dprince): disable format errors since we are not passing kwargs
self.flags(fatal_exception_format_errors=False)
for name in dir(exception):
exc = getattr(exception, name)
if isinstance(exc, type):