diff options
25 files changed, 36 insertions, 207 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_deferred_delete.py b/nova/tests/api/openstack/compute/contrib/test_deferred_delete.py index d02569e00..58102aa62 100644 --- a/nova/tests/api/openstack/compute/contrib/test_deferred_delete.py +++ b/nova/tests/api/openstack/compute/contrib/test_deferred_delete.py @@ -51,7 +51,6 @@ class DeferredDeleteExtensionTest(test.TestCase): self.mox.ReplayAll() res = self.extension._force_delete(self.fake_req, self.fake_uuid, self.fake_input_dict) - self.mox.VerifyAll() self.assertEqual(res.status_int, 202) def test_force_delete_raises_conflict_on_invalid_state(self): @@ -69,7 +68,6 @@ class DeferredDeleteExtensionTest(test.TestCase): self.assertRaises(webob.exc.HTTPConflict, self.extension._force_delete, self.fake_req, self.fake_uuid, self.fake_input_dict) - self.mox.VerifyAll() def test_restore(self): self.mox.StubOutWithMock(compute.API, 'get') @@ -84,7 +82,6 @@ class DeferredDeleteExtensionTest(test.TestCase): self.mox.ReplayAll() res = self.extension._restore(self.fake_req, self.fake_uuid, self.fake_input_dict) - self.mox.VerifyAll() self.assertEqual(res.status_int, 202) def test_restore_raises_conflict_on_invalid_state(self): @@ -101,4 +98,3 @@ class DeferredDeleteExtensionTest(test.TestCase): self.mox.ReplayAll() self.assertRaises(webob.exc.HTTPConflict, self.extension._restore, self.fake_req, self.fake_uuid, self.fake_input_dict) - self.mox.VerifyAll() diff --git a/nova/tests/api/openstack/compute/contrib/test_snapshots.py b/nova/tests/api/openstack/compute/contrib/test_snapshots.py index 8977f5c20..2ad6df555 100644 --- a/nova/tests/api/openstack/compute/contrib/test_snapshots.py +++ b/nova/tests/api/openstack/compute/contrib/test_snapshots.py @@ -15,7 +15,6 @@ import datetime import json -import stubout from lxml import etree import webob @@ -92,7 +91,6 @@ def stub_snapshot_get_all(self, context): class SnapshotApiTest(test.TestCase): def setUp(self): super(SnapshotApiTest, self).setUp() - self.stubs = stubout.StubOutForTesting() fakes.FakeAuthManager.reset_fake_data() fakes.FakeAuthDatabase.data = {} fakes.stub_out_networking(self.stubs) @@ -109,10 +107,6 @@ class SnapshotApiTest(test.TestCase): self.context = context.get_admin_context() - def tearDown(self): - self.stubs.UnsetAll() - super(SnapshotApiTest, self).tearDown() - def test_snapshot_create(self): global _last_param _last_param = {} diff --git a/nova/tests/api/openstack/compute/contrib/test_volume_types.py b/nova/tests/api/openstack/compute/contrib/test_volume_types.py index b8581b99d..1cb0113f6 100644 --- a/nova/tests/api/openstack/compute/contrib/test_volume_types.py +++ b/nova/tests/api/openstack/compute/contrib/test_volume_types.py @@ -76,10 +76,6 @@ class VolumeTypesApiTest(test.TestCase): fakes.stub_out_key_pair_funcs(self.stubs) self.controller = volumetypes.VolumeTypesController() - def tearDown(self): - self.stubs.UnsetAll() - super(VolumeTypesApiTest, self).tearDown() - def test_volume_types_index(self): self.stubs.Set(volume_types, 'get_all_types', return_volume_types_get_all_types) diff --git a/nova/tests/api/openstack/compute/contrib/test_vsa.py b/nova/tests/api/openstack/compute/contrib/test_vsa.py index 9545b4968..c04a3636d 100644 --- a/nova/tests/api/openstack/compute/contrib/test_vsa.py +++ b/nova/tests/api/openstack/compute/contrib/test_vsa.py @@ -380,10 +380,6 @@ class VSADriveApiTest(VSAVolumeApiTest): super(VSADriveApiTest, self).setUp(test_obj="drive", test_objs="drives") - def tearDown(self): - self.stubs.UnsetAll() - super(VSADriveApiTest, self).tearDown() - class SerializerTestCommon(test.TestCase): def _verify_attrs(self, obj, tree, attrs): diff --git a/nova/tests/api/openstack/compute/test_flavors.py b/nova/tests/api/openstack/compute/test_flavors.py index a5fce38cc..7d03a62c0 100644 --- a/nova/tests/api/openstack/compute/test_flavors.py +++ b/nova/tests/api/openstack/compute/test_flavors.py @@ -96,10 +96,6 @@ class FlavorsTest(test.TestCase): self.controller = flavors.Controller() - def tearDown(self): - self.stubs.UnsetAll() - super(FlavorsTest, self).tearDown() - def test_get_flavor_by_invalid_id(self): self.stubs.Set(nova.compute.instance_types, "get_instance_type_by_flavor_id", diff --git a/nova/tests/api/openstack/compute/test_images.py b/nova/tests/api/openstack/compute/test_images.py index cce6afbbd..092485a10 100644 --- a/nova/tests/api/openstack/compute/test_images.py +++ b/nova/tests/api/openstack/compute/test_images.py @@ -23,7 +23,6 @@ and as a WSGI layer import urlparse from lxml import etree -import stubout import webob from nova import flags @@ -51,7 +50,6 @@ class ImagesControllerTest(test.TestCase): def setUp(self): """Run before each test.""" super(ImagesControllerTest, self).setUp() - self.stubs = stubout.StubOutForTesting() fakes.stub_out_networking(self.stubs) fakes.stub_out_rate_limiting(self.stubs) fakes.stub_out_key_pair_funcs(self.stubs) @@ -61,11 +59,6 @@ class ImagesControllerTest(test.TestCase): self.controller = images.Controller() - def tearDown(self): - """Run after each test.""" - self.stubs.UnsetAll() - super(ImagesControllerTest, self).tearDown() - def test_get_image(self): fake_req = fakes.HTTPRequest.blank('/v2/fake/images/123') actual_image = self.controller.show(fake_req, '124') @@ -830,7 +823,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_filter_with_min_ram(self): image_service = self.mox.CreateMockAnything() @@ -841,7 +833,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_filter_with_min_disk(self): image_service = self.mox.CreateMockAnything() @@ -852,7 +843,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_filter_with_status(self): image_service = self.mox.CreateMockAnything() @@ -863,7 +853,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_filter_with_property(self): image_service = self.mox.CreateMockAnything() @@ -874,7 +863,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_filter_server(self): image_service = self.mox.CreateMockAnything() @@ -887,7 +875,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_filter_changes_since(self): image_service = self.mox.CreateMockAnything() @@ -899,7 +886,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_filter_with_type(self): image_service = self.mox.CreateMockAnything() @@ -910,7 +896,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_filter_not_supported(self): image_service = self.mox.CreateMockAnything() @@ -922,7 +907,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.detail(request) - self.mox.VerifyAll() def test_image_no_filters(self): image_service = self.mox.CreateMockAnything() @@ -933,7 +917,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_detail_filter_with_name(self): image_service = self.mox.CreateMockAnything() @@ -945,7 +928,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.detail(request) - self.mox.VerifyAll() def test_image_detail_filter_with_status(self): image_service = self.mox.CreateMockAnything() @@ -957,7 +939,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.detail(request) - self.mox.VerifyAll() def test_image_detail_filter_with_property(self): image_service = self.mox.CreateMockAnything() @@ -969,7 +950,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.detail(request) - self.mox.VerifyAll() def test_image_detail_filter_server_href(self): image_service = self.mox.CreateMockAnything() @@ -983,7 +963,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_detail_filter_server_uuid(self): image_service = self.mox.CreateMockAnything() @@ -996,7 +975,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_detail_filter_changes_since(self): image_service = self.mox.CreateMockAnything() @@ -1008,7 +986,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_detail_filter_with_type(self): image_service = self.mox.CreateMockAnything() @@ -1019,7 +996,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.index(request) - self.mox.VerifyAll() def test_image_detail_filter_not_supported(self): image_service = self.mox.CreateMockAnything() @@ -1031,7 +1007,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.detail(request) - self.mox.VerifyAll() def test_image_detail_no_filters(self): image_service = self.mox.CreateMockAnything() @@ -1042,7 +1017,6 @@ class ImagesControllerTest(test.TestCase): self.mox.ReplayAll() controller = images.Controller(image_service=image_service) controller.detail(request) - self.mox.VerifyAll() def test_generate_alternate_link(self): view = images_view.ViewBuilder() diff --git a/nova/tests/api/openstack/compute/test_server_actions.py b/nova/tests/api/openstack/compute/test_server_actions.py index 42fdcd9a9..f37020619 100644 --- a/nova/tests/api/openstack/compute/test_server_actions.py +++ b/nova/tests/api/openstack/compute/test_server_actions.py @@ -16,7 +16,6 @@ import base64 import mox -import stubout import webob from nova.api.openstack.compute import servers @@ -56,7 +55,6 @@ class ServerActionsControllerTest(test.TestCase): def setUp(self): super(ServerActionsControllerTest, self).setUp() - self.stubs = stubout.StubOutForTesting() fakes.stub_out_auth(self.stubs) self.stubs.Set(nova.db, 'instance_get_by_uuid', fakes.fake_instance_get(vm_state=vm_states.ACTIVE, @@ -81,10 +79,6 @@ class ServerActionsControllerTest(test.TestCase): self.controller = servers.Controller() - def tearDown(self): - self.stubs.UnsetAll() - super(ServerActionsControllerTest, self).tearDown() - def test_server_change_password(self): mock_method = MockSetAdminPassword() self.stubs.Set(nova.compute.api.API, 'set_admin_password', mock_method) @@ -419,7 +413,6 @@ class ServerActionsControllerTest(test.TestCase): self.mox.ReplayAll() self.controller._action_rebuild(req, FAKE_UUID, body) - self.mox.VerifyAll() def test_resize_server(self): diff --git a/nova/tests/api/openstack/compute/test_versions.py b/nova/tests/api/openstack/compute/test_versions.py index eed9b81de..fe19742a7 100644 --- a/nova/tests/api/openstack/compute/test_versions.py +++ b/nova/tests/api/openstack/compute/test_versions.py @@ -19,7 +19,6 @@ import json import feedparser from lxml import etree -import stubout import webob from nova.api.openstack.compute import versions @@ -81,7 +80,6 @@ VERSIONS = { class VersionsTest(test.TestCase): def setUp(self): super(VersionsTest, self).setUp() - self.stubs = stubout.StubOutForTesting() fakes.stub_out_auth(self.stubs) #Stub out VERSIONS self.old_versions = versions.VERSIONS diff --git a/nova/tests/api/openstack/volume/test_types.py b/nova/tests/api/openstack/volume/test_types.py index 462880443..5016732ff 100644 --- a/nova/tests/api/openstack/volume/test_types.py +++ b/nova/tests/api/openstack/volume/test_types.py @@ -76,10 +76,6 @@ class VolumeTypesApiTest(test.TestCase): fakes.stub_out_key_pair_funcs(self.stubs) self.controller = types.VolumeTypesController() - def tearDown(self): - self.stubs.UnsetAll() - super(VolumeTypesApiTest, self).tearDown() - def test_volume_types_index(self): self.stubs.Set(volume_types, 'get_all_types', return_volume_types_get_all_types) diff --git a/nova/tests/baremetal/test_proxy_bare_metal.py b/nova/tests/baremetal/test_proxy_bare_metal.py index 4450e899a..30bc3595b 100644 --- a/nova/tests/baremetal/test_proxy_bare_metal.py +++ b/nova/tests/baremetal/test_proxy_bare_metal.py @@ -18,7 +18,6 @@ import __builtin__ import functools import mox import StringIO -import stubout from nova import flags from nova import utils @@ -53,18 +52,14 @@ class DomainReadWriteTestCase(test.TestCase): """Read a file that contains no domains""" self.mox.StubOutWithMock(__builtin__, 'open') - try: - fake_file = StringIO.StringIO('[]') - open('/tftpboot/test_fake_dom_file', 'r').AndReturn(fake_file) + fake_file = StringIO.StringIO('[]') + open('/tftpboot/test_fake_dom_file', 'r').AndReturn(fake_file) - self.mox.ReplayAll() - - domains = dom.read_domains('/tftpboot/test_fake_dom_file') + self.mox.ReplayAll() - self.assertEqual(domains, []) + domains = dom.read_domains('/tftpboot/test_fake_dom_file') - finally: - self.mox.UnsetStubs() + self.assertEqual(domains, []) def test_read_domain(self): """Read a file that contains at least one domain""" @@ -75,17 +70,13 @@ class DomainReadWriteTestCase(test.TestCase): "ramdisk_id": "", "ip_address": "10.5.1.2"}]''') self.mox.StubOutWithMock(__builtin__, 'open') - try: - open('/tftpboot/test_fake_dom_file', 'r').AndReturn(fake_file) - - self.mox.ReplayAll() + open('/tftpboot/test_fake_dom_file', 'r').AndReturn(fake_file) - domains = dom.read_domains('/tftpboot/test_fake_dom_file') + self.mox.ReplayAll() - self.assertEqual(domains, fake_domains) + domains = dom.read_domains('/tftpboot/test_fake_dom_file') - finally: - self.mox.UnsetStubs() + self.assertEqual(domains, fake_domains) def test_read_no_file(self): """Try to read when the file does not exist @@ -93,18 +84,14 @@ class DomainReadWriteTestCase(test.TestCase): This should through and IO exception""" self.mox.StubOutWithMock(__builtin__, 'open') - try: - open('/tftpboot/test_fake_dom_file', - 'r').AndRaise(IOError(2, 'No such file or directory', + open('/tftpboot/test_fake_dom_file', + 'r').AndRaise(IOError(2, 'No such file or directory', '/tftpboot/test_fake_dom_file')) - self.mox.ReplayAll() - - self.assertRaises(exception.NotFound, dom.read_domains, - '/tftpboot/test_fake_dom_file') + self.mox.ReplayAll() - finally: - self.mox.UnsetStubs() + self.assertRaises(exception.NotFound, dom.read_domains, + '/tftpboot/test_fake_dom_file') def assertJSONEquals(self, x, y): """Check if two json strings represent the equivalent Python object""" @@ -120,23 +107,19 @@ class DomainReadWriteTestCase(test.TestCase): "name": "instance-00000001", "memory_kb": 16777216, "mac_address": "02:16:3e:01:4e:c9", "kernel_id": "1896115634", "ramdisk_id": "", "ip_address": "10.5.1.2"}]''' - try: - open('/tftpboot/test_fake_dom_file', 'w').AndReturn(mock_file) - - # Check if the argument to file.write() represents the same - # Python object as expected_json - # We can't do an exact string comparison - # because of ordering and whitespace - mock_file.write(mox.Func(functools.partial(self.assertJSONEquals, - expected_json))) - mock_file.close() + open('/tftpboot/test_fake_dom_file', 'w').AndReturn(mock_file) - self.mox.ReplayAll() + # Check if the argument to file.write() represents the same + # Python object as expected_json + # We can't do an exact string comparison + # because of ordering and whitespace + mock_file.write(mox.Func(functools.partial(self.assertJSONEquals, + expected_json))) + mock_file.close() - dom.write_domains('/tftpboot/test_fake_dom_file', fake_domains) + self.mox.ReplayAll() - finally: - self.mox.UnsetStubs() + dom.write_domains('/tftpboot/test_fake_dom_file', fake_domains) class BareMetalDomTestCase(test.TestCase): @@ -145,11 +128,9 @@ class BareMetalDomTestCase(test.TestCase): super(BareMetalDomTestCase, self).setUp() self.flags(baremetal_driver='fake') # Stub out utils.execute - self.stubs = stubout.StubOutForTesting() fake_utils.stub_out_utils_execute(self.stubs) def tearDown(self): - self.stubs.UnsetAll() super(BareMetalDomTestCase, self).tearDown() # Reset the singleton state diff --git a/nova/tests/baremetal/test_tilera.py b/nova/tests/baremetal/test_tilera.py index e98ade869..b86e6c9c1 100644 --- a/nova/tests/baremetal/test_tilera.py +++ b/nova/tests/baremetal/test_tilera.py @@ -63,29 +63,22 @@ class TileraBareMetalNodesTestCase(test.TestCase): In this case, we check that it only loads the config file once, even though it has been instantiated multiple times""" - try: - self.mox.StubOutWithMock(__builtin__, 'open') + self.mox.StubOutWithMock(__builtin__, 'open') - open("/tftpboot/tilera_boards", - "r").AndReturn(StringIO.StringIO(self.board_info)) + open("/tftpboot/tilera_boards", + "r").AndReturn(StringIO.StringIO(self.board_info)) - self.mox.ReplayAll() + self.mox.ReplayAll() - nodes = tilera.BareMetalNodes("/tftpboot/tilera_boards") - nodes = tilera.BareMetalNodes("/tftpboot/tilera_boards") - finally: - self.mox.UnsetStubs() + nodes = tilera.BareMetalNodes("/tftpboot/tilera_boards") + nodes = tilera.BareMetalNodes("/tftpboot/tilera_boards") def test_get_hw_info(self): - try: + self.mox.StubOutWithMock(__builtin__, 'open') - self.mox.StubOutWithMock(__builtin__, 'open') + open("/tftpboot/tilera_boards", + "r").AndReturn(StringIO.StringIO(self.board_info)) - open("/tftpboot/tilera_boards", - "r").AndReturn(StringIO.StringIO(self.board_info)) - - self.mox.ReplayAll() - nodes = tilera.BareMetalNodes() - self.assertEqual(nodes.get_hw_info('vcpus'), 10) - finally: - self.mox.UnsetStubs() + self.mox.ReplayAll() + nodes = tilera.BareMetalNodes() + self.assertEqual(nodes.get_hw_info('vcpus'), 10) diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py index 7fac3982d..6d965756a 100644 --- a/nova/tests/image/test_glance.py +++ b/nova/tests/image/test_glance.py @@ -17,7 +17,6 @@ import datetime -import stubout from nova.tests.api.openstack import fakes from nova import context @@ -89,17 +88,12 @@ class TestGlanceImageService(test.TestCase): def setUp(self): super(TestGlanceImageService, self).setUp() - self.stubs = stubout.StubOutForTesting() fakes.stub_out_compute_api_snapshot(self.stubs) client = glance_stubs.StubGlanceClient() self.service = glance.GlanceImageService(client=client) self.context = context.RequestContext('fake', 'fake', auth_token=True) self.service.delete_all() - def tearDown(self): - self.stubs.UnsetAll() - super(TestGlanceImageService, self).tearDown() - @staticmethod def _make_fixture(**kwargs): fixture = {'name': None, diff --git a/nova/tests/notifier/test_list_notifier.py b/nova/tests/notifier/test_list_notifier.py index d71bb279f..6579694e7 100644 --- a/nova/tests/notifier/test_list_notifier.py +++ b/nova/tests/notifier/test_list_notifier.py @@ -52,7 +52,6 @@ class NotifierListTestCase(test.TestCase): self.stubs.Set(nova.notifier.log_notifier, 'notify', mock_notify2) def tearDown(self): - self.stubs.UnsetAll() list_notifier._reset_drivers() super(NotifierListTestCase, self).tearDown() diff --git a/nova/tests/scheduler/test_distributed_scheduler.py b/nova/tests/scheduler/test_distributed_scheduler.py index 950280442..2aa55de0d 100644 --- a/nova/tests/scheduler/test_distributed_scheduler.py +++ b/nova/tests/scheduler/test_distributed_scheduler.py @@ -160,7 +160,6 @@ class DistributedSchedulerTestCase(test_scheduler.SchedulerTestCase): self.mox.ReplayAll() weighted_hosts = sched._schedule(fake_context, 'compute', request_spec) - self.mox.VerifyAll() self.assertEquals(len(weighted_hosts), 10) for weighted_host in weighted_hosts: self.assertTrue(weighted_host.host_state is not None) diff --git a/nova/tests/scheduler/test_host_manager.py b/nova/tests/scheduler/test_host_manager.py index ab0ed56c6..dcd2bce25 100644 --- a/nova/tests/scheduler/test_host_manager.py +++ b/nova/tests/scheduler/test_host_manager.py @@ -84,7 +84,6 @@ class HostManagerTestCase(test.TestCase): self.mox.ReplayAll() filtered_hosts = self.host_manager.filter_hosts(hosts, filter_properties, filters=None) - self.mox.VerifyAll() self.assertEqual(len(filtered_hosts), 1) self.assertEqual(filtered_hosts[0], fake_host2) @@ -108,7 +107,6 @@ class HostManagerTestCase(test.TestCase): host1_volume_capabs) self.host_manager.update_service_capabilities('compute', 'host2', host2_compute_capabs) - self.mox.VerifyAll() # Make sure dictionary isn't re-assigned self.assertEqual(self.host_manager.service_states, service_states) @@ -149,7 +147,6 @@ class HostManagerTestCase(test.TestCase): res1 = self.host_manager.host_service_caps_stale('host1', 'compute') res2 = self.host_manager.host_service_caps_stale('host1', 'volume') res3 = self.host_manager.host_service_caps_stale('host2', 'compute') - self.mox.VerifyAll() self.assertEqual(res1, True) self.assertEqual(res2, False) @@ -229,7 +226,6 @@ class HostManagerTestCase(test.TestCase): self.mox.ReplayAll() result = self.host_manager.get_service_capabilities() - self.mox.VerifyAll() self.assertEqual(info['called'], 5) @@ -258,7 +254,6 @@ class HostManagerTestCase(test.TestCase): self.mox.ReplayAll() host_states = self.host_manager.get_all_host_states(context, topic) - self.mox.VerifyAll() self.assertEqual(len(host_states), 4) # Check that .service is set properly @@ -305,7 +300,6 @@ class HostStateTestCase(test.TestCase): self.mox.ReplayAll() result = fake_host.passes_filters(filter_fns, filter_properties) - self.mox.VerifyAll() self.assertTrue(result) def test_host_state_passes_filters_passes_with_ignore(self): @@ -323,7 +317,6 @@ class HostStateTestCase(test.TestCase): self.mox.ReplayAll() result = fake_host.passes_filters(filter_fns, filter_properties) - self.mox.VerifyAll() self.assertTrue(result) def test_host_state_passes_filters_fails(self): @@ -341,7 +334,6 @@ class HostStateTestCase(test.TestCase): self.mox.ReplayAll() result = fake_host.passes_filters(filter_fns, filter_properties) - self.mox.VerifyAll() self.assertFalse(result) def test_host_state_passes_filters_fails_from_ignore(self): @@ -359,7 +351,6 @@ class HostStateTestCase(test.TestCase): self.mox.ReplayAll() result = fake_host.passes_filters(filter_fns, filter_properties) - self.mox.VerifyAll() self.assertFalse(result) def test_host_state_passes_filters_skipped_from_force(self): @@ -377,5 +368,4 @@ class HostStateTestCase(test.TestCase): self.mox.ReplayAll() result = fake_host.passes_filters(filter_fns, filter_properties) - self.mox.VerifyAll() self.assertTrue(result) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index c91a9dc47..66142070b 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -120,7 +120,6 @@ class BaseTestCase(test.TestCase): self.context = context.RequestContext(self.user_id, self.project_id) test_notifier.NOTIFICATIONS = [] - self.mox = mox.Mox() def fake_show(meh, context, id): return {'id': 1, 'min_disk': None, 'min_ram': None, @@ -131,7 +130,6 @@ class BaseTestCase(test.TestCase): self.stubs.Set(rpc, 'cast', rpc_cast_wrapper) def tearDown(self): - self.mox.UnsetStubs() instances = db.instance_get_all(self.context.elevated()) for instance in instances: db.instance_destroy(self.context.elevated(), instance['id']) @@ -3598,8 +3596,6 @@ class ComputePolicyTestCase(BaseTestCase): nova.policy.enforce(self.context, 'compute:reboot', {}) self.mox.ReplayAll() nova.compute.api.check_policy(self.context, 'reboot', {}) - self.mox.UnsetStubs() - self.mox.VerifyAll() def test_wrapped_method(self): instance = self._create_fake_instance() diff --git a/nova/tests/test_crypto.py b/nova/tests/test_crypto.py index ee4837582..89de1247f 100644 --- a/nova/tests/test_crypto.py +++ b/nova/tests/test_crypto.py @@ -111,8 +111,6 @@ class RevokeCertsTest(test.TestCase): crypto.revoke_certs_by_user_and_project(user_id, project_id) - self.mox.VerifyAll() - def test_revoke_certs_by_user(self): user_id = 'test_user' project_id = 2 @@ -133,8 +131,6 @@ class RevokeCertsTest(test.TestCase): crypto.revoke_certs_by_user(user_id) - self.mox.VerifyAll() - def test_revoke_certs_by_project(self): user_id = 'test_user' project_id = 2 @@ -154,5 +150,3 @@ class RevokeCertsTest(test.TestCase): self.mox.ReplayAll() crypto.revoke_certs_by_project(project_id) - - self.mox.VerifyAll() diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index 2606ba0db..05b931617 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -1463,8 +1463,6 @@ class NetworkPolicyTestCase(test.TestCase): nova.policy.enforce(self.context, 'network:get_all', target) self.mox.ReplayAll() network_manager.check_policy(self.context, 'get_all') - self.mox.UnsetStubs() - self.mox.VerifyAll() class InstanceDNSTestCase(test.TestCase): diff --git a/nova/tests/test_notifier.py b/nova/tests/test_notifier.py index 3eeb864cb..29c5dd080 100644 --- a/nova/tests/test_notifier.py +++ b/nova/tests/test_notifier.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import stubout - import nova import nova.notifier.no_op_notifier from nova import log @@ -28,11 +26,6 @@ class NotifierTestCase(test.TestCase): def setUp(self): super(NotifierTestCase, self).setUp() self.flags(notification_driver='nova.notifier.no_op_notifier') - self.stubs = stubout.StubOutForTesting() - - def tearDown(self): - self.stubs.UnsetAll() - super(NotifierTestCase, self).tearDown() def test_send_notification(self): self.notify_called = False diff --git a/nova/tests/test_nova_manage.py b/nova/tests/test_nova_manage.py index 19f3cce4d..a91657ac4 100644 --- a/nova/tests/test_nova_manage.py +++ b/nova/tests/test_nova_manage.py @@ -21,8 +21,6 @@ import os import StringIO import sys -import stubout - import nova.auth.manager from nova import context from nova import db @@ -44,14 +42,9 @@ sys.dont_write_bytecode = False class FixedIpCommandsTestCase(test.TestCase): def setUp(self): super(FixedIpCommandsTestCase, self).setUp() - self.stubs = stubout.StubOutForTesting() db_fakes.stub_out_db_network_api(self.stubs) self.commands = nova_manage.FixedIpCommands() - def tearDown(self): - super(FixedIpCommandsTestCase, self).tearDown() - self.stubs.UnsetAll() - def test_reserve(self): self.commands.reserve('192.168.0.100') address = db.fixed_ip_get_by_address(context.get_admin_context(), @@ -78,7 +71,6 @@ class FixedIpCommandsTestCase(test.TestCase): class NetworkCommandsTestCase(test.TestCase): def setUp(self): super(NetworkCommandsTestCase, self).setUp() - self.stubs = stubout.StubOutForTesting() self.commands = nova_manage.NetworkCommands() self.net = {'id': 0, 'label': 'fake', @@ -122,10 +114,6 @@ class NetworkCommandsTestCase(test.TestCase): self.fake_network_get_by_uuid = fake_network_get_by_uuid self.fake_network_update = fake_network_update - def tearDown(self): - super(NetworkCommandsTestCase, self).tearDown() - self.stubs.UnsetAll() - def test_create(self): def fake_create_networks(obj, context, **kwargs): diff --git a/nova/tests/test_utils.py b/nova/tests/test_utils.py index 454d1fb7a..e3457dd2d 100644 --- a/nova/tests/test_utils.py +++ b/nova/tests/test_utils.py @@ -374,7 +374,6 @@ class GenericUtilsTestCase(test.TestCase): data = utils.read_cached_file("/this/is/a/fake", cache_data, reload_func=test_reload) - self.mox.UnsetStubs() self.assertEqual(data, fake_contents) self.assertTrue(self.reload_called) diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py index 47376476e..caeaa7098 100644 --- a/nova/tests/test_volume.py +++ b/nova/tests/test_volume.py @@ -455,8 +455,6 @@ class VolumePolicyTestCase(test.TestCase): nova.policy.enforce(self.context, 'volume:attach', target) self.mox.ReplayAll() nova.volume.api.check_policy(self.context, 'attach') - self.mox.UnsetStubs() - self.mox.VerifyAll() def test_check_policy_with_target(self): self.mox.StubOutWithMock(nova.policy, 'enforce') @@ -468,5 +466,3 @@ class VolumePolicyTestCase(test.TestCase): nova.policy.enforce(self.context, 'volume:attach', target) self.mox.ReplayAll() nova.volume.api.check_policy(self.context, 'attach', {'id': 2}) - self.mox.UnsetStubs() - self.mox.VerifyAll() diff --git a/nova/tests/test_vsa.py b/nova/tests/test_vsa.py index 0089d8a2f..f3c4c421b 100644 --- a/nova/tests/test_vsa.py +++ b/nova/tests/test_vsa.py @@ -14,7 +14,6 @@ # under the License. import base64 -import stubout from xml.etree import ElementTree @@ -37,7 +36,6 @@ class VsaTestCase(test.TestCase): def setUp(self): super(VsaTestCase, self).setUp() - self.stubs = stubout.StubOutForTesting() self.vsa_api = vsa.API() self.flags(quota_volumes=100, quota_gigabytes=10000) @@ -62,10 +60,6 @@ class VsaTestCase(test.TestCase): 'show_by_name', fake_show_by_name) - def tearDown(self): - self.stubs.UnsetAll() - super(VsaTestCase, self).tearDown() - def test_vsa_create_delete_defaults(self): param = {'display_name': 'VSA name test'} vsa_ref = self.vsa_api.create(self.context, **param) diff --git a/nova/tests/test_vsa_volumes.py b/nova/tests/test_vsa_volumes.py index bd0ce2921..2d898ec1e 100644 --- a/nova/tests/test_vsa_volumes.py +++ b/nova/tests/test_vsa_volumes.py @@ -50,7 +50,6 @@ class VsaVolumesTestCase(test.TestCase): def tearDown(self): if self.vsa_id: self.vsa_api.delete(self.context, self.vsa_id) - self.stubs.UnsetAll() super(VsaVolumesTestCase, self).tearDown() def _default_volume_param(self): diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index f8b0c1791..aa818709d 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -22,7 +22,6 @@ import datetime import functools import os import re -import stubout from nova import db from nova import context @@ -89,7 +88,6 @@ class XenAPIVolumeTestCase(test.TestCase): """Unit tests for Volume operations.""" def setUp(self): super(XenAPIVolumeTestCase, self).setUp() - self.stubs = stubout.StubOutForTesting() self.user_id = 'fake' self.project_id = 'fake' self.context = context.RequestContext(self.user_id, self.project_id) @@ -210,10 +208,6 @@ class XenAPIVolumeTestCase(test.TestCase): volume['id'], '/dev/sdc') - def tearDown(self): - super(XenAPIVolumeTestCase, self).tearDown() - self.stubs.UnsetAll() - def configure_instance(*args): pass @@ -228,7 +222,6 @@ class XenAPIVMTestCase(test.TestCase): def setUp(self): super(XenAPIVMTestCase, self).setUp() self.network = utils.import_object(FLAGS.network_manager) - self.stubs = stubout.StubOutForTesting() self.flags(xenapi_connection_url='test_url', xenapi_connection_password='test_pass', instance_name_template='%d', @@ -831,7 +824,6 @@ class XenAPIMigrateInstance(test.TestCase): def setUp(self): super(XenAPIMigrateInstance, self).setUp() - self.stubs = stubout.StubOutForTesting() self.flags(target_host='127.0.0.1', xenapi_connection_url='test_url', xenapi_connection_password='test_pass', @@ -1141,7 +1133,6 @@ class XenAPIHostTestCase(test.TestCase): def setUp(self): super(XenAPIHostTestCase, self).setUp() - self.stubs = stubout.StubOutForTesting() self.flags(xenapi_connection_url='test_url', xenapi_connection_password='test_pass') stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests) @@ -1192,7 +1183,6 @@ class XenAPIHostTestCase(test.TestCase): class XenAPIAutoDiskConfigTestCase(test.TestCase): def setUp(self): super(XenAPIAutoDiskConfigTestCase, self).setUp() - self.stubs = stubout.StubOutForTesting() self.flags(target_host='127.0.0.1', xenapi_connection_url='test_url', xenapi_connection_password='test_pass', @@ -1284,7 +1274,6 @@ class XenAPIGenerateLocal(test.TestCase): """Test generating of local disks, like swap and ephemeral""" def setUp(self): super(XenAPIGenerateLocal, self).setUp() - self.stubs = stubout.StubOutForTesting() self.flags(target_host='127.0.0.1', xenapi_connection_url='test_url', xenapi_connection_password='test_pass', @@ -1364,7 +1353,6 @@ class XenAPIGenerateLocal(test.TestCase): class XenAPIBWUsageTestCase(test.TestCase): def setUp(self): super(XenAPIBWUsageTestCase, self).setUp() - self.stubs = stubout.StubOutForTesting() self.stubs.Set(vm_utils.VMHelper, "compile_metrics", XenAPIBWUsageTestCase._fake_compile_metrics) self.flags(target_host='127.0.0.1', @@ -1437,7 +1425,6 @@ class XenAPIDom0IptablesFirewallTestCase(test.TestCase): instance_name_template='%d', firewall_driver='nova.virt.xenapi.firewall.' 'Dom0IptablesFirewallDriver') - self.stubs = stubout.StubOutForTesting() xenapi_fake.reset() xenapi_fake.create_local_srs() xenapi_fake.create_local_pifs() @@ -1701,14 +1688,9 @@ class XenAPISRSelectionTestCase(test.TestCase): """Unit tests for testing we find the right SR.""" def setUp(self): super(XenAPISRSelectionTestCase, self).setUp() - self.stubs = stubout.StubOutForTesting() stubs.stub_out_get_target(self.stubs) xenapi_fake.reset() - def tearDown(self): - super(XenAPISRSelectionTestCase, self).tearDown() - self.stubs.UnsetAll() - def test_safe_find_sr_raise_exception(self): """Ensure StorageRepositoryNotFound is raise when wrong filter.""" self.flags(sr_matching_filter='yadayadayada') @@ -1769,7 +1751,6 @@ class XenAPIAggregateTestCase(test.TestCase): """Unit tests for aggregate operations.""" def setUp(self): super(XenAPIAggregateTestCase, self).setUp() - self.stubs = stubout.StubOutForTesting() self.flags(xenapi_connection_url='http://test_url', xenapi_connection_username='test_user', xenapi_connection_password='test_pass', @@ -1786,10 +1767,6 @@ class XenAPIAggregateTestCase(test.TestCase): 'host': xenapi_fake.get_record('host', host_ref)['uuid']} - def tearDown(self): - super(XenAPIAggregateTestCase, self).tearDown() - self.stubs.UnsetAll() - def test_add_to_aggregate_called(self): def fake_add_to_aggregate(context, aggregate, host): fake_add_to_aggregate.called = True |