From be11fd9fcde171cfb1cc1c2216fed4270dbc9221 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Tue, 18 Dec 2012 10:08:37 -0500 Subject: [PATCH] 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 --- nova/tests/test_libvirt.py | 10 ++++++---- nova/tests/test_misc.py | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 778391dd..fb3c756e 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -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() diff --git a/nova/tests/test_misc.py b/nova/tests/test_misc.py index 4e989f31..2ed8fed3 100644 --- a/nova/tests/test_misc.py +++ b/nova/tests/test_misc.py @@ -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):