diff --git a/nova/tests/functional/libvirt/test_numa_servers.py b/nova/tests/functional/libvirt/test_numa_servers.py index ce5e7c7541b2..3aea72f04bda 100644 --- a/nova/tests/functional/libvirt/test_numa_servers.py +++ b/nova/tests/functional/libvirt/test_numa_servers.py @@ -13,13 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib import mock import fixtures from oslo_config import cfg from oslo_log import log as logging +from nova import test from nova.tests.functional.test_servers import ServersTestBase from nova.tests.unit import fake_network from nova.tests.unit.virt.libvirt import fake_libvirt_utils @@ -137,7 +137,7 @@ class NUMAServersTest(ServersTestBase): extra_spec = {'hw:numa_nodes': '2'} flavor_id = self._create_flavor(extra_spec=extra_spec) host_pass_mock = self._get_topology_filter_spy() - with contextlib.nested( + with test.nested( mock.patch('nova.virt.libvirt.host.Host.get_connection', return_value=fake_connection), mock.patch('nova.scheduler.filters' @@ -160,7 +160,7 @@ class NUMAServersTest(ServersTestBase): flavor_id = self._create_flavor(extra_spec=extra_spec) host_pass_mock = self._get_topology_filter_spy() - with contextlib.nested( + with test.nested( mock.patch('nova.virt.libvirt.host.Host.get_connection', return_value=fake_connection), mock.patch('nova.scheduler.filters' diff --git a/nova/tests/unit/api/openstack/compute/legacy_v2/test_servers.py b/nova/tests/unit/api/openstack/compute/legacy_v2/test_servers.py index 4d67b8ed4cc3..d3b2b1104979 100644 --- a/nova/tests/unit/api/openstack/compute/legacy_v2/test_servers.py +++ b/nova/tests/unit/api/openstack/compute/legacy_v2/test_servers.py @@ -17,7 +17,6 @@ import base64 import collections -import contextlib import datetime import urllib import uuid @@ -1751,7 +1750,7 @@ class ServersControllerRebuildInstanceTest(ControllerTest): return dict(id='76fa36fc-c930-4bf3-8c8a-ea2a2420deb6', name='public image', is_public=True, status='active') - with contextlib.nested( + with test.nested( mock.patch.object(fake._FakeImageService, 'show', side_effect=fake_get_image), mock.patch.object(self.controller.compute_api, 'rebuild', diff --git a/nova/tests/unit/api/openstack/compute/test_floating_ips.py b/nova/tests/unit/api/openstack/compute/test_floating_ips.py index 675f299cbae8..67f4b42a76c7 100644 --- a/nova/tests/unit/api/openstack/compute/test_floating_ips.py +++ b/nova/tests/unit/api/openstack/compute/test_floating_ips.py @@ -14,7 +14,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib import uuid import mock @@ -122,7 +121,7 @@ class FloatingIpTestNeutronV21(test.NoDBTestCase): def test_floatingip_delete(self): req = fakes.HTTPRequest.blank('') fip_val = {'address': '1.1.1.1', 'fixed_ip_id': '192.168.1.2'} - with contextlib.nested( + with test.nested( mock.patch.object(self.controller.network_api, 'disassociate_floating_ip'), mock.patch.object(self.controller.network_api, @@ -146,11 +145,8 @@ class FloatingIpTestNeutronV21(test.NoDBTestCase): def _test_floatingip_delete_not_found(self, ex, expect_ex=webob.exc.HTTPNotFound): req = fakes.HTTPRequest.blank('') - with contextlib.nested( - mock.patch.object(self.controller.network_api, - 'get_floating_ip', - side_effect=ex) - ): + with mock.patch.object(self.controller.network_api, + 'get_floating_ip', side_effect=ex): self.assertRaises(expect_ex, self.controller.delete, req, 1) @@ -239,7 +235,7 @@ class FloatingIpTestV21(test.TestCase): def test_floatingip_delete(self): fip_val = {'address': '1.1.1.1', 'fixed_ip_id': '192.168.1.2'} - with contextlib.nested( + with test.nested( mock.patch.object(self.controller.network_api, 'disassociate_floating_ip'), mock.patch.object(self.controller.network_api, @@ -257,11 +253,8 @@ class FloatingIpTestV21(test.TestCase): def _test_floatingip_delete_not_found(self, ex, expect_ex=webob.exc.HTTPNotFound): - with contextlib.nested( - mock.patch.object(self.controller.network_api, - 'get_floating_ip', - side_effect=ex) - ): + with mock.patch.object(self.controller.network_api, + 'get_floating_ip', side_effect=ex): self.assertRaises(expect_ex, self.controller.delete, self.fake_req, 1) diff --git a/nova/tests/unit/api/openstack/compute/test_serversV21.py b/nova/tests/unit/api/openstack/compute/test_serversV21.py index 5b36a7828cf9..574db7147885 100644 --- a/nova/tests/unit/api/openstack/compute/test_serversV21.py +++ b/nova/tests/unit/api/openstack/compute/test_serversV21.py @@ -16,7 +16,6 @@ import base64 import collections -import contextlib import copy import datetime import uuid @@ -1663,7 +1662,7 @@ class ServersControllerRebuildInstanceTest(ControllerTest): return dict(id='76fa36fc-c930-4bf3-8c8a-ea2a2420deb6', name='public image', is_public=True, status='active') - with contextlib.nested( + with test.nested( mock.patch.object(fake._FakeImageService, 'show', side_effect=fake_get_image), mock.patch.object(self.controller.compute_api, 'rebuild', diff --git a/nova/tests/unit/cells/test_cells_messaging.py b/nova/tests/unit/cells/test_cells_messaging.py index de3a6dcbb573..af207f4506cb 100644 --- a/nova/tests/unit/cells/test_cells_messaging.py +++ b/nova/tests/unit/cells/test_cells_messaging.py @@ -17,7 +17,6 @@ Tests For Cells Messaging module """ -import contextlib import uuid import mock @@ -1089,7 +1088,7 @@ class CellsTargetedMethodsTestCase(test.TestCase): instance.uuid = uuidutils.generate_uuid() error = exception.InstanceInfoCacheNotFound( instance_uuid=instance.uuid) - with contextlib.nested( + with test.nested( mock.patch.object(instance, 'refresh', side_effect=error), mock.patch.object(self.tgt_compute_api, 'delete')) as (inst, diff --git a/nova/tests/unit/cert/test_rpcapi.py b/nova/tests/unit/cert/test_rpcapi.py index fe1287b3e185..34743f853799 100644 --- a/nova/tests/unit/cert/test_rpcapi.py +++ b/nova/tests/unit/cert/test_rpcapi.py @@ -16,8 +16,6 @@ Unit Tests for nova.cert.rpcapi """ -import contextlib - import mock from oslo_config import cfg @@ -38,7 +36,7 @@ class CertRpcAPITestCase(test.NoDBTestCase): orig_prepare = rpcapi.client.prepare - with contextlib.nested( + with test.nested( mock.patch.object(rpcapi.client, 'call'), mock.patch.object(rpcapi.client, 'prepare'), mock.patch.object(rpcapi.client, 'can_send_version'), diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index def46b846783..4eca3c76cabb 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -18,7 +18,6 @@ """Tests for compute service.""" import base64 -import contextlib import datetime import operator import sys @@ -407,7 +406,7 @@ class ComputeVolumeTestCase(BaseTestCase): def fake_attach(*args, **kwargs): raise test.TestingException - with contextlib.nested( + with test.nested( mock.patch.object(driver_block_device.DriverVolumeBlockDevice, 'attach'), mock.patch.object(cinder.API, 'unreserve_volume'), @@ -425,7 +424,7 @@ class ComputeVolumeTestCase(BaseTestCase): fake_bdm = objects.BlockDeviceMapping(**self.fake_volume) instance = self._create_fake_instance_obj() - with contextlib.nested( + with test.nested( mock.patch.object(self.compute, '_driver_detach_volume'), mock.patch.object(self.compute.volume_api, 'detach'), mock.patch.object(objects.BlockDeviceMapping, @@ -5118,7 +5117,7 @@ class ComputeTestCase(BaseTestCase): self.context.elevated(), instance.uuid, 'pre-migrating') - with contextlib.nested( + with test.nested( mock.patch.object(objects.BlockDeviceMappingList, 'get_by_instance_uuid', return_value='fake_bdms'), mock.patch.object( @@ -5742,7 +5741,7 @@ class ComputeTestCase(BaseTestCase): migrate_data = {'migration': mock.MagicMock()} # creating mocks - with contextlib.nested( + with test.nested( mock.patch.object(self.compute.driver, 'post_live_migration'), mock.patch.object(self.compute.driver, 'unfilter_instance'), mock.patch.object(self.compute.network_api, @@ -5804,7 +5803,7 @@ class ComputeTestCase(BaseTestCase): 'volume_id': 'fake-volume-id'}), ]) - with contextlib.nested( + with test.nested( mock.patch.object(self.compute.network_api, 'migrate_instance_start'), mock.patch.object(self.compute.compute_rpcapi, @@ -6562,7 +6561,7 @@ class ComputeTestCase(BaseTestCase): instances.append(fake_instance.fake_db_instance(**new_instance)) # creating mocks - with contextlib.nested( + with test.nested( mock.patch.object(self.compute.db.sqlalchemy.api, 'instance_get_all_by_filters', return_value=instances), @@ -7262,7 +7261,7 @@ class ComputeTestCase(BaseTestCase): self.context, [root_volume, blank_volume1, blank_volume2, ephemeral, swap]) - with contextlib.nested( + with test.nested( mock.patch.object(self.compute, '_default_root_device_name', return_value='/dev/vda'), mock.patch.object(objects.BlockDeviceMapping, 'save'), @@ -9273,7 +9272,7 @@ class ComputeAPITestCase(BaseTestCase): rpcapi = compute_rpcapi.ComputeAPI - with contextlib.nested( + with test.nested( mock.patch.object(rpcapi, 'get_serial_console', return_value=fake_connect_info), mock.patch.object(self.compute_api.consoleauth_rpcapi, @@ -9310,7 +9309,7 @@ class ComputeAPITestCase(BaseTestCase): 'instance_uuid': fake_instance.uuid, 'access_url': 'fake_access_url'} - with contextlib.nested( + with test.nested( mock.patch.object(self.compute_api.compute_rpcapi, 'get_mks_console', return_value=fake_connect_info), @@ -9389,7 +9388,7 @@ class ComputeAPITestCase(BaseTestCase): port_id = nwinfo[0]['id'] req_ip = '1.2.3.4' - with contextlib.nested( + with test.nested( mock.patch.object(self.compute.driver, 'attach_interface'), mock.patch.object(self.compute.network_api, 'allocate_port_for_instance'), @@ -9429,7 +9428,7 @@ class ComputeAPITestCase(BaseTestCase): instance.info_cache.network_info = network_model.NetworkInfo.hydrate( nwinfo) - with contextlib.nested( + with test.nested( mock.patch.object(self.compute.driver, 'detach_interface', side_effect=exception.NovaException('detach_failed')), mock.patch.object(self.compute.network_api, @@ -9456,7 +9455,7 @@ class ComputeAPITestCase(BaseTestCase): # to make sure we catch those in the compute manager and not just # NovaExceptions. error = neutron_exceptions.PortNotFoundClient() - with contextlib.nested( + with test.nested( mock.patch.object(self.compute.driver, 'detach_interface'), mock.patch.object(self.compute.network_api, 'deallocate_port_for_instance', @@ -9482,7 +9481,7 @@ class ComputeAPITestCase(BaseTestCase): instance = self._create_fake_instance_obj() fake_volume = {'id': 'fake-volume-id'} - with contextlib.nested( + with test.nested( mock.patch.object(cinder.API, 'get', return_value=fake_volume), mock.patch.object(cinder.API, 'check_attach'), mock.patch.object(cinder.API, 'reserve_volume'), @@ -9672,7 +9671,7 @@ class ComputeAPITestCase(BaseTestCase): 'connection_info': '{"test": "test"}'}) bdm = objects.BlockDeviceMapping(context=self.context, **fake_bdm) - with contextlib.nested( + with test.nested( mock.patch.object(self.compute.driver, 'detach_volume', side_effect=exception.DiskNotFound('sdb')), mock.patch.object(objects.BlockDeviceMapping, @@ -10687,7 +10686,7 @@ class ComputeAPIAggrCallsSchedulerTestCase(test.NoDBTestCase): self.api._update_az_cache_for_host = mock.Mock() agg = objects.Aggregate(name='fake', metadata={}) agg.add_host = mock.Mock() - with contextlib.nested( + with test.nested( mock.patch.object(objects.Service, 'get_by_compute_host'), mock.patch.object(objects.Aggregate, 'get_by_id', return_value=agg)): @@ -10699,7 +10698,7 @@ class ComputeAPIAggrCallsSchedulerTestCase(test.NoDBTestCase): self.api._update_az_cache_for_host = mock.Mock() agg = objects.Aggregate(name='fake', metadata={}) agg.delete_host = mock.Mock() - with contextlib.nested( + with test.nested( mock.patch.object(objects.Service, 'get_by_compute_host'), mock.patch.object(objects.Aggregate, 'get_by_id', return_value=agg)): diff --git a/nova/tests/unit/compute/test_compute_api.py b/nova/tests/unit/compute/test_compute_api.py index 53404021523d..ac0c10229850 100644 --- a/nova/tests/unit/compute/test_compute_api.py +++ b/nova/tests/unit/compute/test_compute_api.py @@ -13,7 +13,6 @@ """Unit tests for compute API.""" -import contextlib import copy import datetime @@ -434,7 +433,7 @@ class _ComputeAPIUnitTestMixIn(object): params = dict(task_state=None, vm_state=vm_state, display_name='fake-name') instance = self._create_instance_obj(params=params) - with contextlib.nested( + with test.nested( mock.patch.object(self.compute_api, 'is_volume_backed_instance', return_value=boot_from_volume), mock.patch.object(self.compute_api, '_create_image', @@ -509,7 +508,7 @@ class _ComputeAPIUnitTestMixIn(object): def _test_shelve_offload(self, clean_shutdown=True): params = dict(task_state=None, vm_state=vm_states.SHELVED) instance = self._create_instance_obj(params=params) - with contextlib.nested( + with test.nested( mock.patch.object(instance, 'save'), mock.patch.object(self.compute_api.compute_rpcapi, 'shelve_offload_instance') @@ -1063,7 +1062,7 @@ class _ComputeAPIUnitTestMixIn(object): def test_local_delete_without_info_cache(self): inst = self._create_instance_obj() - with contextlib.nested( + with test.nested( mock.patch.object(inst, 'destroy'), mock.patch.object(self.context, 'elevated'), mock.patch.object(self.compute_api.network_api, @@ -2321,7 +2320,7 @@ class _ComputeAPIUnitTestMixIn(object): fake_volume = {"volume_image_metadata": {"min_ram": 256, "min_disk": 128, "foo": "bar"}} fake_snapshot = {"volume_id": "1"} - with contextlib.nested( + with test.nested( mock.patch.object(self.compute_api.volume_api, 'get', return_value=fake_volume), mock.patch.object(self.compute_api.volume_api, 'get_snapshot', @@ -2761,7 +2760,7 @@ class _ComputeAPIUnitTestMixIn(object): rescue_image=None, clean_shutdown=True): instance = self._create_instance_obj(params={'vm_state': vm_state}) bdms = [] - with contextlib.nested( + with test.nested( mock.patch.object(objects.BlockDeviceMappingList, 'get_by_instance_uuid', return_value=bdms), mock.patch.object(self.compute_api, 'is_volume_backed_instance', @@ -2815,7 +2814,7 @@ class _ComputeAPIUnitTestMixIn(object): def test_unrescue(self): instance = self._create_instance_obj( params={'vm_state': vm_states.RESCUED}) - with contextlib.nested( + with test.nested( mock.patch.object(instance, 'save'), mock.patch.object(self.compute_api, '_record_action_start'), mock.patch.object(self.compute_api.compute_rpcapi, diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py index 00740c0df7e0..c403fd8b6809 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -12,7 +12,6 @@ """Unit tests for ComputeManager().""" -import contextlib import time import uuid @@ -220,7 +219,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): expected_attrs=['system_metadata']) quotas = mock.create_autospec(objects.Quotas, spec_set=True) - with contextlib.nested( + with test.nested( mock.patch.object(self.compute, '_notify_about_instance_usage'), mock.patch.object(self.compute, '_shutdown_instance'), mock.patch.object(instance, 'obj_load_attr'), @@ -544,7 +543,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): host=self.compute.host, expected_attrs=['info_cache']) - with contextlib.nested( + with test.nested( mock.patch.object(context, 'get_admin_context', return_value=self.context), mock.patch.object(compute_utils, 'get_nw_info_for_instance', @@ -838,7 +837,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): vm_state=vm_states.ACTIVE, host=self.compute.host, task_state=task_states.MIGRATING) - with contextlib.nested( + with test.nested( mock.patch.object(instance, 'save'), mock.patch('nova.compute.utils.get_nw_info_for_instance', return_value=network_model.NetworkInfo()) @@ -1058,7 +1057,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): task_state=task_states.RESIZE_PREP, power_state=power_state.RUNNING) - with contextlib.nested( + with test.nested( mock.patch.object(self.compute, '_get_power_state', return_value=power_state.RUNNING), mock.patch.object(compute_utils, 'get_nw_info_for_instance'), @@ -1107,7 +1106,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): def _test_init_instance_retries_reboot(self, instance, reboot_type, return_power_state): instance.host = self.compute.host - with contextlib.nested( + with test.nested( mock.patch.object(self.compute, '_get_power_state', return_value=return_power_state), mock.patch.object(self.compute, 'reboot_instance'), @@ -1177,7 +1176,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): def _test_init_instance_cleans_reboot_state(self, instance): instance.host = self.compute.host - with contextlib.nested( + with test.nested( mock.patch.object(self.compute, '_get_power_state', return_value=power_state.RUNNING), mock.patch.object(instance, 'save', autospec=True), @@ -2217,7 +2216,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): self.context, vm_state=vm_states.ACTIVE) fake_nw_info = network_model.NetworkInfo() rescue_image_meta = {'id': 'fake', 'name': 'fake'} - with contextlib.nested( + with test.nested( mock.patch.object(self.context, 'elevated', return_value=self.context), mock.patch.object(self.compute.network_api, 'get_instance_nw_info', @@ -2285,7 +2284,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): instance = fake_instance.fake_instance_obj( self.context, vm_state=vm_states.RESCUED) fake_nw_info = network_model.NetworkInfo() - with contextlib.nested( + with test.nested( mock.patch.object(self.context, 'elevated', return_value=self.context), mock.patch.object(self.compute.network_api, 'get_instance_nw_info', @@ -2458,7 +2457,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): # Only instance 2 has a migration record migration = objects.Migration(instance_uuid=instance_2.uuid) - with contextlib.nested( + with test.nested( mock.patch.object(self.compute, '_get_instances_on_driver', return_value=[instance_1, instance_2]), @@ -2665,7 +2664,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): self.assertEqual(block_device_info['block_device_mapping'], 'shared_block_storage') - with contextlib.nested( + with test.nested( mock.patch.object(self.compute.driver, 'destroy', return_value=None), mock.patch.object(self.compute.driver, 'spawn', @@ -3345,7 +3344,7 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase): self._instance_action_events() self.mox.ReplayAll() - with contextlib.nested( + with test.nested( mock.patch('nova.utils.spawn_n'), mock.patch('nova.hooks._HOOKS') ) as ( @@ -3487,7 +3486,7 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase): reason="")) def _test_build_and_run_spawn_exceptions(self, exc): - with contextlib.nested( + with test.nested( mock.patch.object(self.compute.driver, 'spawn', side_effect=exc), mock.patch.object(self.instance, 'save', @@ -3625,7 +3624,7 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase): self.assertIsInstance(e, exception.BuildAbortException) def test_failed_bdm_prep_from_delete_raises_unexpected(self): - with contextlib.nested( + with test.nested( mock.patch.object(self.compute, '_build_networks_for_instance', return_value=self.network_info), @@ -3876,7 +3875,7 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase): self.requested_networks, self.security_groups) def test_cleanup_allocated_networks_instance_not_found(self): - with contextlib.nested( + with test.nested( mock.patch.object(self.compute, '_deallocate_network'), mock.patch.object(self.instance, 'save', side_effect=exception.InstanceNotFound(instance_id='')) @@ -3897,7 +3896,7 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase): # Check that launched_at is set on the instance self.assertIsNotNone(args[1].launched_at) - with contextlib.nested( + with test.nested( mock.patch.object(self.compute, '_update_scheduler_instance_info'), mock.patch.object(self.compute.driver, 'spawn'), @@ -3964,7 +3963,7 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase): exc = exception.InstanceNotFound(instance_id='') - with contextlib.nested( + with test.nested( mock.patch.object(self.compute.driver, 'spawn'), mock.patch.object(self.compute, '_build_networks_for_instance', return_value=[]), @@ -4027,7 +4026,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase): mock_obj_as_admin.assert_called_once_with() def test_finish_resize_failure(self): - with contextlib.nested( + with test.nested( mock.patch.object(self.compute, '_finish_resize', side_effect=exception.ResizeError(reason='')), mock.patch.object(db, 'instance_fault_create'), @@ -4052,7 +4051,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase): def test_resize_instance_failure(self): self.migration.dest_host = None - with contextlib.nested( + with test.nested( mock.patch.object(self.compute.driver, 'migrate_disk_and_power_off', side_effect=exception.ResizeError(reason='')), diff --git a/nova/tests/unit/compute/test_host_api.py b/nova/tests/unit/compute/test_host_api.py index 555f20e0b35d..5f914b3d3ebb 100644 --- a/nova/tests/unit/compute/test_host_api.py +++ b/nova/tests/unit/compute/test_host_api.py @@ -14,7 +14,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib import copy import mock @@ -310,7 +309,7 @@ class ComputeHostAPITestCase(test.TestCase): self.assertEqual('fake-response', result) def test_service_delete(self): - with contextlib.nested( + with test.nested( mock.patch.object(objects.Service, 'get_by_id', return_value=objects.Service()), mock.patch.object(objects.Service, 'destroy') diff --git a/nova/tests/unit/compute/test_rpcapi.py b/nova/tests/unit/compute/test_rpcapi.py index 8f9e347f980a..2e9652ae1fb3 100644 --- a/nova/tests/unit/compute/test_rpcapi.py +++ b/nova/tests/unit/compute/test_rpcapi.py @@ -16,8 +16,6 @@ Unit Tests for nova.compute.rpcapi """ -import contextlib - import mock from oslo_config import cfg from oslo_serialization import jsonutils @@ -112,7 +110,7 @@ class ComputeRpcAPITestCase(test.NoDBTestCase): if method == 'rebuild_instance' and 'node' in expected_kwargs: expected_kwargs['scheduled_node'] = expected_kwargs.pop('node') - with contextlib.nested( + with test.nested( mock.patch.object(rpcapi.client, rpc_method), mock.patch.object(rpcapi.client, 'prepare'), mock.patch.object(rpcapi.client, 'can_send_version'), diff --git a/nova/tests/unit/compute/test_tracker.py b/nova/tests/unit/compute/test_tracker.py index 801c28956589..667daa66accc 100644 --- a/nova/tests/unit/compute/test_tracker.py +++ b/nova/tests/unit/compute/test_tracker.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib import copy import mock @@ -398,7 +397,7 @@ def setup_rt(hostname, nodename, virt_resources=_VIRT_DRIVER_AVAIL_RESOURCES, vd.get_available_resource.return_value = virt_resources vd.estimate_instance_overhead.side_effect = estimate_overhead - with contextlib.nested( + with test.nested( mock.patch('nova.scheduler.client.SchedulerClient', return_value=sched_client_mock), mock.patch('nova.rpc.get_notifier', return_value=notifier_mock)): @@ -1345,7 +1344,7 @@ class TestMoveClaim(BaseTestCase): # Initialise extensible resource trackers self.flags(reserved_host_disk_mb=0, reserved_host_memory_mb=0) - with contextlib.nested( + with test.nested( mock.patch('nova.objects.InstanceList.get_by_host_and_node'), mock.patch('nova.objects.MigrationList.' 'get_in_progress_by_host_and_node') diff --git a/nova/tests/unit/conductor/test_conductor.py b/nova/tests/unit/conductor/test_conductor.py index c710e7dfb05d..d42181f6ba9a 100644 --- a/nova/tests/unit/conductor/test_conductor.py +++ b/nova/tests/unit/conductor/test_conductor.py @@ -15,7 +15,6 @@ """Tests for the conductor service.""" -import contextlib import copy import uuid @@ -624,7 +623,7 @@ class _BaseTaskTestCase(object): # 'shelved_image_id' is None for volumebacked instance instance.system_metadata['shelved_image_id'] = None - with contextlib.nested( + with test.nested( mock.patch.object(self.conductor_manager, '_schedule_instances'), mock.patch.object(self.conductor_manager.compute_rpcapi, @@ -680,7 +679,7 @@ class _BaseTaskTestCase(object): *instances): raise exc.NoValidHost(reason='') - with contextlib.nested( + with test.nested( mock.patch.object(self.conductor_manager.image_api, 'get', return_value='fake_image'), mock.patch.object(self.conductor_manager, '_schedule_instances', @@ -754,7 +753,7 @@ class _BaseTaskTestCase(object): rebuild_args, compute_args = self._prepare_rebuild_args( {'host': inst_obj.host}) - with contextlib.nested( + with test.nested( mock.patch.object(self.conductor_manager.compute_rpcapi, 'rebuild_instance'), mock.patch.object(self.conductor_manager.scheduler_client, @@ -779,7 +778,7 @@ class _BaseTaskTestCase(object): request_spec = {} filter_properties = {'ignore_hosts': [(inst_obj.host)]} - with contextlib.nested( + with test.nested( mock.patch.object(self.conductor_manager.compute_rpcapi, 'rebuild_instance'), mock.patch.object(scheduler_utils, 'setup_instance_group', @@ -812,7 +811,7 @@ class _BaseTaskTestCase(object): request_spec = {} filter_properties = {'ignore_hosts': [(inst_obj.host)]} - with contextlib.nested( + with test.nested( mock.patch.object(self.conductor_manager.compute_rpcapi, 'rebuild_instance'), mock.patch.object(scheduler_utils, 'setup_instance_group', @@ -886,7 +885,7 @@ class _BaseTaskTestCase(object): rebuild_args, compute_args = self._prepare_rebuild_args( {'host': inst_obj.host, 'migration': migration}) - with contextlib.nested( + with test.nested( mock.patch.object(self.conductor_manager.compute_rpcapi, 'rebuild_instance'), mock.patch.object(self.conductor_manager.scheduler_client, @@ -1150,7 +1149,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase): resvs = 'fake-resvs' image = 'fake-image' - with contextlib.nested( + with test.nested( mock.patch.object(utils, 'get_image_from_system_metadata', return_value=image), mock.patch.object(scheduler_utils, 'build_request_spec', @@ -1289,7 +1288,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase): resvs = 'fake-resvs' image = 'fake-image' - with contextlib.nested( + with test.nested( mock.patch.object(utils, 'get_image_from_system_metadata', return_value=image), mock.patch.object(scheduler_utils, 'build_request_spec', @@ -1374,7 +1373,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase): spec = {'fake': 'specs', 'instance_properties': instances[0]} build_request_spec.return_value = spec - with contextlib.nested( + with test.nested( mock.patch.object(instances[0], 'refresh', side_effect=exc.InstanceInfoCacheNotFound( instance_uuid=instances[0].uuid)), diff --git a/nova/tests/unit/console/test_rpcapi.py b/nova/tests/unit/console/test_rpcapi.py index 74265b598bde..38d01fe42a52 100644 --- a/nova/tests/unit/console/test_rpcapi.py +++ b/nova/tests/unit/console/test_rpcapi.py @@ -16,8 +16,6 @@ Unit Tests for nova.console.rpcapi """ -import contextlib - import mock from oslo_config import cfg @@ -38,7 +36,7 @@ class ConsoleRpcAPITestCase(test.NoDBTestCase): orig_prepare = rpcapi.client.prepare - with contextlib.nested( + with test.nested( mock.patch.object(rpcapi.client, rpc_method), mock.patch.object(rpcapi.client, 'prepare'), mock.patch.object(rpcapi.client, 'can_send_version'), diff --git a/nova/tests/unit/consoleauth/test_rpcapi.py b/nova/tests/unit/consoleauth/test_rpcapi.py index bff7a28eda3c..fab3eb7398f6 100644 --- a/nova/tests/unit/consoleauth/test_rpcapi.py +++ b/nova/tests/unit/consoleauth/test_rpcapi.py @@ -16,8 +16,6 @@ Unit Tests for nova.consoleauth.rpcapi """ -import contextlib - import mock from oslo_config import cfg import six @@ -47,7 +45,7 @@ class ConsoleAuthRpcAPITestCase(test.NoDBTestCase): rpc_kwargs = {k: v for k, v in six.iteritems(kwargs) if v is not self.DROPPED_ARG} - with contextlib.nested( + with test.nested( mock.patch.object(rpcapi.client, 'cast' if do_cast else 'call'), mock.patch.object(rpcapi.client, 'prepare'), mock.patch.object(rpcapi.client, 'can_send_version'), diff --git a/nova/tests/unit/network/test_api.py b/nova/tests/unit/network/test_api.py index 3e2dcaba6d88..2c5cef415f2f 100644 --- a/nova/tests/unit/network/test_api.py +++ b/nova/tests/unit/network/test_api.py @@ -15,7 +15,6 @@ """Tests for network API.""" -import contextlib import itertools import uuid @@ -448,7 +447,7 @@ class ApiTestCase(test.TestCase): def _test_refresh_cache(self, method, *args, **kwargs): # This test verifies that no call to get_instance_nw_info() is made # from the @refresh_cache decorator for the tested method. - with contextlib.nested( + with test.nested( mock.patch.object(self.network_api.network_rpcapi, method), mock.patch.object(self.network_api.network_rpcapi, 'get_instance_nw_info'), diff --git a/nova/tests/unit/network/test_linux_net.py b/nova/tests/unit/network/test_linux_net.py index 5fbd05ec0ef3..e47f719bb547 100644 --- a/nova/tests/unit/network/test_linux_net.py +++ b/nova/tests/unit/network/test_linux_net.py @@ -14,7 +14,6 @@ # under the License. import calendar -import contextlib import datetime import os import time @@ -1149,7 +1148,7 @@ class LinuxNetworkTestCase(test.NoDBTestCase): 'global'), ] } - with contextlib.nested( + with test.nested( mock.patch.object(linux_net, 'device_exists', return_value=True), mock.patch.object(linux_net, '_execute', return_value=('', '')), mock.patch.object(netifaces, 'ifaddresses') @@ -1168,7 +1167,7 @@ class LinuxNetworkTestCase(test.NoDBTestCase): else: return ('', '') - with contextlib.nested( + with test.nested( mock.patch.object(linux_net, 'device_exists', return_value=True), mock.patch.object(linux_net, '_execute', fake_execute) ) as (device_exists, _): @@ -1185,7 +1184,7 @@ class LinuxNetworkTestCase(test.NoDBTestCase): else: return ('', '') - with contextlib.nested( + with test.nested( mock.patch.object(linux_net, 'device_exists', return_value=False), mock.patch.object(linux_net, '_execute', fake_execute) ) as (device_exists, _): diff --git a/nova/tests/unit/network/test_manager.py b/nova/tests/unit/network/test_manager.py index 35b7880e5983..f4c19b9b3713 100644 --- a/nova/tests/unit/network/test_manager.py +++ b/nova/tests/unit/network/test_manager.py @@ -15,8 +15,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib - import fixtures import mock from mox3 import mox @@ -712,7 +710,7 @@ class FlatNetworkTestCase(test.TestCase): mock_vif_get.return_value = vif_obj.VirtualInterface( instance_uuid='fake-uuid', id=1) - with contextlib.nested( + with test.nested( mock.patch.object(self.network, '_setup_network_on_host'), mock.patch.object(self.network, 'instance_dns_manager'), mock.patch.object(self.network, @@ -764,7 +762,7 @@ class FlatNetworkTestCase(test.TestCase): mock_instance_get.return_value = instance mock_vif_get.return_value = None - with contextlib.nested( + with test.nested( mock.patch.object(self.network, '_setup_network_on_host'), mock.patch.object(self.network, 'instance_dns_manager'), mock.patch.object(self.network, @@ -1726,7 +1724,7 @@ class VlanNetworkTestCase(test.TestCase): def vif_get(_context, _vif_id): return vifs[0] - with contextlib.nested( + with test.nested( mock.patch.object(db, 'virtual_interface_get', vif_get), mock.patch.object( utils, 'execute', diff --git a/nova/tests/unit/network/test_neutronv2.py b/nova/tests/unit/network/test_neutronv2.py index 98a54a9fa184..5161f0d983c6 100644 --- a/nova/tests/unit/network/test_neutronv2.py +++ b/nova/tests/unit/network/test_neutronv2.py @@ -15,7 +15,6 @@ # import collections -import contextlib import copy import uuid @@ -2872,7 +2871,7 @@ class TestNeutronv2WithMock(test.TestCase): return return_value self.fail('Unexpected call to list_ports %s' % search_opts) - with contextlib.nested( + with test.nested( mock.patch.object(client.Client, 'list_ports', side_effect=_fake_list_ports), mock.patch.object(client.Client, 'list_networks', @@ -2914,7 +2913,7 @@ class TestNeutronv2WithMock(test.TestCase): if args == search_opts: return return_value - with contextlib.nested( + with test.nested( mock.patch.object(self.api, '_get_available_networks', return_value=nets), mock.patch.object(client.Client, 'list_ports', @@ -3007,7 +3006,7 @@ class TestNeutronv2WithMock(test.TestCase): # Verify that the correct exception is thrown when quota exceed pool_name = 'dummy' api = neutronapi.API() - with contextlib.nested( + with test.nested( mock.patch.object(client.Client, 'create_floatingip'), mock.patch.object(api, '_get_floating_ip_pool_id_by_name_or_id')) as ( @@ -3023,7 +3022,7 @@ class TestNeutronv2WithMock(test.TestCase): net_id = uuid.uuid4() error_msg = ('Bad floatingip request: Network %s does not contain ' 'any IPv4 subnet' % net_id) - with contextlib.nested( + with test.nested( mock.patch.object(client.Client, 'create_floatingip'), mock.patch.object(api, '_get_floating_ip_pool_id_by_name_or_id')) as ( @@ -3159,7 +3158,7 @@ class TestNeutronv2WithMock(test.TestCase): # setup mocks mock_client = mock.Mock() mock_client.list_ports.return_value = port_data - with contextlib.nested( + with test.nested( mock.patch.object(neutronapi, 'get_client', return_value=mock_client), mock.patch.object(api, '_delete_ports') @@ -3203,7 +3202,7 @@ class TestNeutronv2WithMock(test.TestCase): mock_preexisting.return_value = [] mock_client = mock.Mock() api = neutronapi.API() - with contextlib.nested( + with test.nested( mock.patch.object(neutronapi, 'get_client', return_value=mock_client), mock.patch.object(api, '_delete_ports', diff --git a/nova/tests/unit/network/test_rpcapi.py b/nova/tests/unit/network/test_rpcapi.py index e45a98a77e9a..6929488316ef 100644 --- a/nova/tests/unit/network/test_rpcapi.py +++ b/nova/tests/unit/network/test_rpcapi.py @@ -17,7 +17,6 @@ Unit Tests for nova.network.rpcapi """ import collections -import contextlib import mock from mox3 import mox @@ -217,7 +216,7 @@ class NetworkRpcAPITestCase(test.NoDBTestCase): rpcapi = network_rpcapi.NetworkAPI() cast_mock = mock.Mock() cctxt_mock = mock.Mock(cast=cast_mock) - with contextlib.nested( + with test.nested( mock.patch.object(rpcapi.client, 'can_send_version', return_value=False), mock.patch.object(rpcapi.client, 'prepare', @@ -246,7 +245,7 @@ class NetworkRpcAPITestCase(test.NoDBTestCase): rpcapi = network_rpcapi.NetworkAPI() call_mock = mock.Mock() cctxt_mock = mock.Mock(call=call_mock) - with contextlib.nested( + with test.nested( mock.patch.object(rpcapi.client, 'can_send_version', return_value=False), mock.patch.object(rpcapi.client, 'prepare', diff --git a/nova/tests/unit/virt/hyperv/test_volumeops.py b/nova/tests/unit/virt/hyperv/test_volumeops.py index 183649f2e5ac..4ac7fcb07f2c 100644 --- a/nova/tests/unit/virt/hyperv/test_volumeops.py +++ b/nova/tests/unit/virt/hyperv/test_volumeops.py @@ -14,13 +14,13 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib import os import mock from oslo_config import cfg from nova import exception +from nova import test from nova.tests.unit import fake_block_device from nova.tests.unit.virt.hyperv import test_base from nova.virt.hyperv import pathutils @@ -87,7 +87,7 @@ class VolumeOpsTestCase(test_base.HyperVBaseTestCase): fake_vol_conn_info = ( block_device_info['block_device_mapping'][0]['connection_info']) - with contextlib.nested( + with test.nested( mock.patch.object(self._volumeops, '_get_volume_driver'), mock.patch.object(self._volumeops, @@ -308,7 +308,7 @@ class ISCSIVolumeDriverTestCase(test_base.HyperVBaseTestCase): mock.sentinel.fake_iqn) def test_get_mounted_disk_from_lun(self): - with contextlib.nested( + with test.nested( mock.patch.object(self._volume_driver._volutils, 'get_device_number_for_target'), mock.patch.object(self._volume_driver._vmutils, diff --git a/nova/tests/unit/virt/libvirt/storage/test_lvm.py b/nova/tests/unit/virt/libvirt/storage/test_lvm.py index 83220e261c47..0480b6c7d42c 100644 --- a/nova/tests/unit/virt/libvirt/storage/test_lvm.py +++ b/nova/tests/unit/virt/libvirt/storage/test_lvm.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib - import mock from oslo_concurrency import processutils from oslo_config import cfg @@ -181,7 +179,7 @@ class LvmTestCase(test.NoDBTestCase): if 'vol2' in args: raise processutils.ProcessExecutionError('Error') - with contextlib.nested( + with test.nested( mock.patch.object(lvm, 'clear_volume'), mock.patch.object(libvirt_utils, 'execute', side_effect=fake_execute)) as (mock_clear, mock_execute): diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 06b0c7599299..8c922b4a5b70 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -1110,7 +1110,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) conf = mock.Mock() - with contextlib.nested( + with test.nested( mock.patch.object(libvirt_driver.LOG, 'debug', side_effect=fake_debug), mock.patch.object(drvr, '_get_guest_config', return_value=conf) @@ -1302,7 +1302,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance_ref, image_meta) - with contextlib.nested( + with test.nested( mock.patch.object(host.Host, 'has_min_version', return_value=True), mock.patch.object(host.Host, "get_capabilities", @@ -1332,7 +1332,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance_ref, image_meta) - with contextlib.nested( + with test.nested( mock.patch.object(host.Host, "get_capabilities", return_value=caps), mock.patch.object( @@ -1441,7 +1441,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): numa_node=None) pci_device = objects.PciDevice(**pci_device_info) - with contextlib.nested( + with test.nested( mock.patch.object(host.Host, 'has_min_version', return_value=True), mock.patch.object( @@ -1488,7 +1488,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): pci_device = objects.PciDevice(**pci_device_info) pci_device_info.update(numa_node=0, address='0000:00:00.2') pci_device2 = objects.PciDevice(**pci_device_info) - with contextlib.nested( + with test.nested( mock.patch.object( host.Host, "get_capabilities", return_value=caps), mock.patch.object( @@ -1672,7 +1672,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance_ref, image_meta) - with contextlib.nested( + with test.nested( mock.patch.object(host.Host, 'has_min_version', return_value=True), mock.patch.object(host.Host, "get_capabilities", @@ -1716,7 +1716,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance_ref, image_meta) - with contextlib.nested( + with test.nested( mock.patch.object( objects.InstanceNUMATopology, "get_by_instance_uuid", return_value=instance_topology), @@ -1763,7 +1763,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance_ref, image_meta) - with contextlib.nested( + with test.nested( mock.patch.object( objects.InstanceNUMATopology, "get_by_instance_uuid", return_value=instance_topology), @@ -1841,7 +1841,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance_ref, image_meta) - with contextlib.nested( + with test.nested( mock.patch.object( objects.InstanceNUMATopology, "get_by_instance_uuid", return_value=instance_topology), @@ -1918,7 +1918,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance_ref, image_meta) - with contextlib.nested( + with test.nested( mock.patch.object( objects.InstanceNUMATopology, "get_by_instance_uuid", return_value=instance_topology), @@ -1995,7 +1995,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance_ref, image_meta) - with contextlib.nested( + with test.nested( mock.patch.object( objects.InstanceNUMATopology, "get_by_instance_uuid", return_value=instance_topology), @@ -3497,7 +3497,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance_id='foo') drvr._conn.defineXML = mock.Mock() drvr._conn.defineXML.side_effect = ValueError('somethingbad') - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_is_booted_from_volume', return_value=False), mock.patch.object(drvr, 'plug_vifs'), @@ -3889,7 +3889,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): def test_get_guest_config_sysinfo_serial_os(self): self.flags(sysinfo_serial="os", group="libvirt") theuuid = "56b40135-a973-4eb3-87bb-a2382a3e6dbc" - with contextlib.nested( + with test.nested( mock.patch('__builtin__.open', mock.mock_open(read_data=theuuid)), self.patch_exists(True)): @@ -3897,7 +3897,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): def test_get_guest_config_sysinfo_serial_os_empty_machine_id(self): self.flags(sysinfo_serial="os", group="libvirt") - with contextlib.nested( + with test.nested( mock.patch('__builtin__.open', mock.mock_open(read_data="")), self.patch_exists(True)): self.assertRaises(exception.NovaException, @@ -3915,7 +3915,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): self.flags(sysinfo_serial="auto", group="libvirt") real_exists = os.path.exists - with contextlib.nested( + with test.nested( mock.patch.object(os.path, "exists"), mock.patch.object(libvirt_driver.LibvirtDriver, "_get_host_sysinfo_serial_hardware") @@ -3937,7 +3937,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): real_exists = os.path.exists real_open = builtins.open - with contextlib.nested( + with test.nested( mock.patch.object(os.path, "exists"), mock.patch.object(builtins, "open"), ) as (mock_exists, mock_open): @@ -5079,7 +5079,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): flags = (fakelibvirt.VIR_DOMAIN_AFFECT_CONFIG | fakelibvirt.VIR_DOMAIN_AFFECT_LIVE) - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_connect_volume'), mock.patch.object(drvr, '_get_volume_config', return_value=mock_conf), @@ -6147,7 +6147,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) (mock_getsize, mock_lookup) =\ self._is_shared_block_storage_test_create_mocks(disks) - with contextlib.nested( + with test.nested( mock.patch.object(os.path, 'getsize', mock_getsize), mock.patch.object(host.Host, 'get_domain', mock_lookup)): self.assertFalse(drvr._is_shared_block_storage( @@ -7190,7 +7190,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): 'project_id': 'fake-project'}) instance = objects.Instance(**self.test_instance) - with contextlib.nested( + with test.nested( mock.patch.object(libvirt_driver.libvirt_utils, 'copy_image'), mock.patch.object(libvirt_driver.libvirt_utils, 'fetch_image', side_effect=exception.ImageNotFound( @@ -7272,7 +7272,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): base_dir = os.path.join(CONF.instances_path, CONF.image_cache_subdirectory_name) instance = objects.Instance(**self.test_instance) - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_fetch_instance_kernel_ramdisk'), mock.patch.object(libvirt_driver.libvirt_utils, 'fetch_image'), mock.patch.object(drvr, '_create_ephemeral'), @@ -7543,7 +7543,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) instance = objects.Instance(**self.test_instance) # creating mocks - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_create_images_and_backing'), mock.patch.object(drvr, @@ -7576,7 +7576,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): fallback_from_host=False): self.assertTrue(instance_dir) # creating mocks - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_create_images_and_backing', side_effect=check_instance_dir), @@ -7681,7 +7681,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): cntx = context.get_admin_context() # Set up the mock expectations - with contextlib.nested( + with test.nested( mock.patch.object(driver, 'block_device_info_get_mapping', return_value=vol['block_device_mapping']), mock.patch.object(drvr, "get_volume_connector", @@ -8053,7 +8053,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): image_meta = {} drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_create_images_and_backing'), mock.patch.object(drvr, 'plug_vifs'), mock.patch.object(drvr.firewall_driver, 'setup_basic_filtering'), @@ -8399,7 +8399,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): image_meta) disk_info['mapping'].pop('disk.local') - with contextlib.nested( + with test.nested( mock.patch.object(utils, 'execute'), mock.patch.object(drvr, 'get_info'), mock.patch.object(drvr, '_create_domain_and_network'), @@ -8612,7 +8612,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) service_mock = mock.MagicMock() service_mock.disabled.return_value = False - with contextlib.nested( + with test.nested( mock.patch.object(drvr._host, "_connect", side_effect=fakelibvirt.make_libvirtError( fakelibvirt.libvirtError, @@ -8636,7 +8636,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) service_mock = mock.MagicMock() service_mock.disabled.return_value = False - with contextlib.nested( + with test.nested( mock.patch.object(drvr._host, "_connect", side_effect=fakelibvirt.make_libvirtError( fakelibvirt.libvirtError, @@ -8662,7 +8662,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) service_mock = mock.MagicMock() service_mock.disabled.return_value = True - with contextlib.nested( + with test.nested( mock.patch.object(drvr._host, "_connect", return_value=mock.MagicMock()), mock.patch.object(drvr._host, "_init_events", @@ -9235,7 +9235,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): block_device_info = None drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) guest = libvirt_guest.Guest('fake_dom') - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_get_existing_domain_xml', return_value=dummyxml), mock.patch.object(drvr, '_create_domain_and_network', @@ -9868,7 +9868,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): {'cpus': '', 'cpu_usage': 0, 'mem': {'total': 256, 'used': 0}, 'id': 3}]} - with contextlib.nested( + with test.nested( mock.patch.object(host.Host, "get_capabilities", return_value=caps), mock.patch.object( @@ -9930,7 +9930,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): caps.host.topology = None drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) - with contextlib.nested( + with test.nested( mock.patch.object(host.Host, 'has_min_version', return_value=True), mock.patch.object(host.Host, "get_capabilities", return_value=caps) @@ -10807,7 +10807,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) drvr.get_host_ip_addr = mock.MagicMock(return_value='bar') mock_exists.return_value = is_same - with contextlib.nested( + with test.nested( mock.patch.object(drvr._remotefs, 'create_file'), mock.patch.object(drvr._remotefs, 'remove_file') ) as (mock_rem_fs_create, mock_rem_fs_remove): @@ -10900,7 +10900,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): mock_get_info.return_value = hardware.InstanceInfo( state=power_state.RUNNING) - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_create_images_and_backing'), mock.patch.object(drvr, '_is_booted_from_volume', return_value=False), @@ -10964,7 +10964,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): mock_get_info.return_value = hardware.InstanceInfo( state=power_state.RUNNING) - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_create_images_and_backing'), mock.patch.object(drvr, '_is_booted_from_volume', return_value=False), @@ -11020,7 +11020,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): mock_get_info.return_value = hardware.InstanceInfo( state=power_state.SHUTDOWN) - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_create_images_and_backing'), mock.patch.object(drvr, '_is_booted_from_volume', return_value=False), @@ -11225,7 +11225,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance = objects.Instance(**self.test_instance) drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) - with contextlib.nested( + with test.nested( mock.patch.object(host.Host, 'get_domain', side_effect=exception.InstanceNotFound( instance_id=instance.uuid)), @@ -11504,7 +11504,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): ])} block_device_info['block_device_mapping'][0]['connection_info'] = ( {'driver_volume_type': 'iscsi'}) - with contextlib.nested( + with test.nested( mock.patch.object( driver_block_device.DriverVolumeBlockDevice, 'save'), mock.patch.object(objects.Instance, 'save') @@ -11522,7 +11522,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance = objects.Instance(id=1, uuid='fake-uuid', image_ref='my_fake_image') - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_create_domain_setup_lxc'), mock.patch.object(drvr, '_create_domain_cleanup_lxc'), mock.patch.object(drvr, '_is_booted_from_volume', @@ -11548,7 +11548,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) instance = objects.Instance(**self.test_instance) - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_lxc_disk_handler', side_effect=fake_lxc_disk_handler), mock.patch.object(drvr, 'plug_vifs'), @@ -11711,7 +11711,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): network_info = [network_model.VIF(id='1'), network_model.VIF(id='2', active=True)] - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_get_volume_encryptor'), mock.patch.object(drvr, 'plug_vifs'), mock.patch.object(drvr.firewall_driver, 'setup_basic_filtering'), @@ -11766,7 +11766,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): bdi) mock_conf = mock.MagicMock(source_path='fake') - with contextlib.nested( + with test.nested( mock.patch.object(driver_block_device.DriverVolumeBlockDevice, 'save'), mock.patch.object(drvr, '_connect_volume'), @@ -12003,7 +12003,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): mock_dom = mock.MagicMock() - with contextlib.nested( + with test.nested( mock.patch.object(drvr._conn, 'defineXML', create=True), mock.patch.object(fake_libvirt_utils, 'get_disk_size'), mock.patch.object(fake_libvirt_utils, 'get_disk_backing_file'), @@ -12859,7 +12859,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase): def test_disk_resize_qcow2( self, mock_extend, mock_can_resize, mock_is_image_extendable): - with contextlib.nested( + with test.nested( mock.patch.object( self.drvr, '_disk_qcow2_to_raw'), mock.patch.object( @@ -13102,7 +13102,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase): drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_create_domain_and_network'), mock.patch.object(utils, 'get_image_from_system_metadata', return_value=image_meta), @@ -13531,7 +13531,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase): rescue_file = os.path.join('/path', 'rescue.file') drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) - with contextlib.nested( + with test.nested( mock.patch.object(drvr, '_destroy'), mock.patch.object(drvr, '_create_domain'), mock.patch.object(libvirt_utils, 'file_delete'), @@ -14682,7 +14682,7 @@ class LibvirtVolumeSnapshotTestCase(test.NoDBTestCase): domain = FakeVirtDomain(fake_xml=self.dom_xml) guest = libvirt_guest.Guest(domain) - with contextlib.nested( + with test.nested( mock.patch.object(domain, 'XMLDesc', return_value=self.dom_xml), mock.patch.object(self.drvr._host, 'get_guest', return_value=guest), @@ -14714,7 +14714,7 @@ class LibvirtVolumeSnapshotTestCase(test.NoDBTestCase): domain = FakeVirtDomain(fake_xml=self.dom_netdisk_xml_2) guest = libvirt_guest.Guest(domain) - with contextlib.nested( + with test.nested( mock.patch.object(domain, 'XMLDesc', return_value=self.dom_netdisk_xml_2), mock.patch.object(self.drvr._host, 'get_guest', diff --git a/nova/tests/unit/virt/libvirt/test_host.py b/nova/tests/unit/virt/libvirt/test_host.py index 8186f7cf5390..c1fae46df8a1 100644 --- a/nova/tests/unit/virt/libvirt/test_host.py +++ b/nova/tests/unit/virt/libvirt/test_host.py @@ -14,7 +14,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib import uuid import eventlet @@ -772,7 +771,7 @@ Cached: 8362404 kB SwapCached: 0 kB Active: 8381604 kB """) - with contextlib.nested( + with test.nested( mock.patch("__builtin__.open", m, create=True), mock.patch.object(host.Host, "get_connection"), @@ -813,7 +812,7 @@ SwapCached: 0 kB Active: 8381604 kB """) - with contextlib.nested( + with test.nested( mock.patch("__builtin__.open", m, create=True), mock.patch.object(host.Host, "list_instance_domains"), diff --git a/nova/tests/unit/virt/libvirt/test_imagebackend.py b/nova/tests/unit/virt/libvirt/test_imagebackend.py index 29fe79de647e..0746652cb923 100644 --- a/nova/tests/unit/virt/libvirt/test_imagebackend.py +++ b/nova/tests/unit/virt/libvirt/test_imagebackend.py @@ -14,7 +14,6 @@ # under the License. import base64 -import contextlib import inspect import os import shutil @@ -809,7 +808,7 @@ class EncryptedLvmTestCase(_ImageTestCase, test.NoDBTestCase): self.dmcrypt = imagebackend.dmcrypt def _create_image(self, sparse): - with contextlib.nested( + with test.nested( mock.patch.object(self.lvm, 'create_volume', mock.Mock()), mock.patch.object(self.lvm, 'remove_volumes', mock.Mock()), mock.patch.object(self.disk, 'resize2fs', mock.Mock()), @@ -851,7 +850,7 @@ class EncryptedLvmTestCase(_ImageTestCase, test.NoDBTestCase): self.utils.execute.assert_called_with(*cmd, run_as_root=True) def _create_image_generated(self, sparse): - with contextlib.nested( + with test.nested( mock.patch.object(self.lvm, 'create_volume', mock.Mock()), mock.patch.object(self.lvm, 'remove_volumes', mock.Mock()), mock.patch.object(self.disk, 'resize2fs', mock.Mock()), @@ -888,7 +887,7 @@ class EncryptedLvmTestCase(_ImageTestCase, test.NoDBTestCase): ephemeral_size=None, context=self.CONTEXT) def _create_image_resize(self, sparse): - with contextlib.nested( + with test.nested( mock.patch.object(self.lvm, 'create_volume', mock.Mock()), mock.patch.object(self.lvm, 'remove_volumes', mock.Mock()), mock.patch.object(self.disk, 'resize2fs', mock.Mock()), @@ -953,7 +952,7 @@ class EncryptedLvmTestCase(_ImageTestCase, test.NoDBTestCase): self._create_image_resize(True) def test_create_image_negative(self): - with contextlib.nested( + with test.nested( mock.patch.object(self.lvm, 'create_volume', mock.Mock()), mock.patch.object(self.lvm, 'remove_volumes', mock.Mock()), mock.patch.object(self.disk, 'resize2fs', mock.Mock()), @@ -995,7 +994,7 @@ class EncryptedLvmTestCase(_ImageTestCase, test.NoDBTestCase): self.lvm.remove_volumes.assert_called_with([self.LV_PATH]) def test_create_image_encrypt_negative(self): - with contextlib.nested( + with test.nested( mock.patch.object(self.lvm, 'create_volume', mock.Mock()), mock.patch.object(self.lvm, 'remove_volumes', mock.Mock()), mock.patch.object(self.disk, 'resize2fs', mock.Mock()), @@ -1042,7 +1041,7 @@ class EncryptedLvmTestCase(_ImageTestCase, test.NoDBTestCase): self.lvm.remove_volumes.assert_called_with([self.LV_PATH]) def test_create_image_generated_negative(self): - with contextlib.nested( + with test.nested( mock.patch.object(self.lvm, 'create_volume', mock.Mock()), mock.patch.object(self.lvm, 'remove_volumes', mock.Mock()), mock.patch.object(self.disk, 'resize2fs', mock.Mock()), @@ -1088,7 +1087,7 @@ class EncryptedLvmTestCase(_ImageTestCase, test.NoDBTestCase): self.lvm.remove_volumes.assert_called_with([self.LV_PATH]) def test_create_image_generated_encrypt_negative(self): - with contextlib.nested( + with test.nested( mock.patch.object(self.lvm, 'create_volume', mock.Mock()), mock.patch.object(self.lvm, 'remove_volumes', mock.Mock()), mock.patch.object(self.disk, 'resize2fs', mock.Mock()), diff --git a/nova/tests/unit/virt/libvirt/test_vif.py b/nova/tests/unit/virt/libvirt/test_vif.py index 73c650457cda..e31ad0721722 100644 --- a/nova/tests/unit/virt/libvirt/test_vif.py +++ b/nova/tests/unit/virt/libvirt/test_vif.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib - from lxml import etree import mock from oslo_concurrency import processutils @@ -684,7 +682,7 @@ class LibvirtVifTestCase(test.NoDBTestCase): 'ca:fe:de:ad:be:ef', 'instance-uuid')] } - with contextlib.nested( + with test.nested( mock.patch.object(linux_net, 'device_exists', return_value=False), mock.patch.object(utils, 'execute'), @@ -709,7 +707,7 @@ class LibvirtVifTestCase(test.NoDBTestCase): 'qbrvif-xxx-yyy', run_as_root=True)], 'delete_ovs_vif_port': [mock.call('br0', 'qvovif-xxx-yyy')] } - with contextlib.nested( + with test.nested( mock.patch.object(linux_net, 'device_exists', return_value=True), mock.patch.object(utils, 'execute'), @@ -767,7 +765,7 @@ class LibvirtVifTestCase(test.NoDBTestCase): 'device_exists': [mock.call('qbrvif-xxx-yyy')], 'delete_ovs_vif_port': [mock.call('br0', 'qvovif-xxx-yyy')] } - with contextlib.nested( + with test.nested( mock.patch.object(linux_net, 'device_exists', return_value=False), mock.patch.object(linux_net, 'delete_ovs_vif_port') @@ -801,7 +799,7 @@ class LibvirtVifTestCase(test.NoDBTestCase): 'ca:fe:de:ad:be:ef', 'instance-uuid')] } - with contextlib.nested( + with test.nested( mock.patch.object(linux_net, 'device_exists', return_value=False), mock.patch.object(utils, 'execute'), @@ -825,7 +823,7 @@ class LibvirtVifTestCase(test.NoDBTestCase): 'qbrvif-xxx-yyy', run_as_root=True)], 'delete_ivs_vif_port': [mock.call('qvovif-xxx-yyy')] } - with contextlib.nested( + with test.nested( mock.patch.object(utils, 'execute'), mock.patch.object(linux_net, 'delete_ivs_vif_port') ) as (execute, delete_ivs_vif_port): @@ -1295,7 +1293,7 @@ class LibvirtVifTestCase(test.NoDBTestCase): 'instance-uuid')], 'ovs_set_vhostuser_port_type': [mock.call('usv-xxx-yyy-zzz')] } - with contextlib.nested( + with test.nested( mock.patch.object(linux_net, 'create_ovs_vif_port'), mock.patch.object(linux_net, 'ovs_set_vhostuser_port_type') ) as (create_ovs_vif_port, ovs_set_vhostuser_port_type): diff --git a/nova/tests/unit/virt/test_block_device.py b/nova/tests/unit/virt/test_block_device.py index de6e363441c4..f022a76244ad 100644 --- a/nova/tests/unit/virt/test_block_device.py +++ b/nova/tests/unit/virt/test_block_device.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib - import mock from oslo_serialization import jsonutils import six @@ -682,7 +680,7 @@ class TestDriverBlockDevice(test.NoDBTestCase): instance = fake_instance.fake_instance_obj(mock.sentinel.ctx, **{'uuid': 'fake-uuid'}) - with contextlib.nested( + with test.nested( mock.patch.object(self.volume_api, 'get_snapshot', return_value=snapshot), mock.patch.object(self.volume_api, 'create', return_value=volume), @@ -788,7 +786,7 @@ class TestDriverBlockDevice(test.NoDBTestCase): instance = fake_instance.fake_instance_obj(mock.sentinel.ctx, **{'uuid': 'fake-uuid'}) - with contextlib.nested( + with test.nested( mock.patch.object(self.volume_api, 'create', return_value=volume), mock.patch.object(self.volume_api, 'delete'), ) as (vol_create, vol_delete): @@ -841,7 +839,7 @@ class TestDriverBlockDevice(test.NoDBTestCase): volume = {'id': 'fake-volume-id-2', 'display_name': 'fake-uuid-blank-vol'} - with contextlib.nested( + with test.nested( mock.patch.object(self.volume_api, 'create', return_value=volume), mock.patch.object(self.volume_api, 'delete'), ) as (vol_create, vol_delete): @@ -874,7 +872,7 @@ class TestDriverBlockDevice(test.NoDBTestCase): volume = {'id': 'fake-volume-id-2', 'display_name': 'fake-uuid-blank-vol'} - with contextlib.nested( + with test.nested( mock.patch.object(self.volume_api, 'create', return_value=volume), mock.patch.object(volume_class, 'attach') ) as (vol_create, vol_attach): diff --git a/nova/tests/unit/virt/vmwareapi/test_driver_api.py b/nova/tests/unit/virt/vmwareapi/test_driver_api.py index 75adc8a4c6b5..4141a7853050 100644 --- a/nova/tests/unit/virt/vmwareapi/test_driver_api.py +++ b/nova/tests/unit/virt/vmwareapi/test_driver_api.py @@ -20,7 +20,6 @@ Test suite for VMwareAPI. """ import collections -import contextlib import datetime from eventlet import greenthread @@ -135,7 +134,7 @@ class VMwareSessionTestCase(test.NoDBTestCase): @mock.patch.object(driver.VMwareAPISession, '_is_vim_object', return_value=False) def test_call_method(self, mock_is_vim): - with contextlib.nested( + with test.nested( mock.patch.object(driver.VMwareAPISession, '_create_session', _fake_create_session), mock.patch.object(driver.VMwareAPISession, 'invoke_api'), @@ -149,7 +148,7 @@ class VMwareSessionTestCase(test.NoDBTestCase): @mock.patch.object(driver.VMwareAPISession, '_is_vim_object', return_value=True) def test_call_method_vim(self, mock_is_vim): - with contextlib.nested( + with test.nested( mock.patch.object(driver.VMwareAPISession, '_create_session', _fake_create_session), mock.patch.object(driver.VMwareAPISession, 'invoke_api'), @@ -836,7 +835,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): mock_from_image.return_value = img_props - with contextlib.nested( + with test.nested( mock.patch.object(self.conn._vmops, '_extend_virtual_disk'), mock.patch.object(self.conn._vmops, 'get_datacenter_ref_and_name'), ) as (mock_extend, mock_get_dc): @@ -872,7 +871,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): return self.call_method(module, method, *args, **kwargs) - with contextlib.nested( + with test.nested( mock.patch.object(self.conn._session, '_call_method', new=fake_call_method), mock.patch.object(self.conn._session, '_wait_for_task', @@ -908,7 +907,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): self.task_ref = task_ref return task_ref - with contextlib.nested( + with test.nested( mock.patch.object(self.conn._session, '_call_method', new=fake_call_method), mock.patch.object(self.conn._session, '_wait_for_task', @@ -952,7 +951,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): self.task_ref = task_ref return task_ref - with contextlib.nested( + with test.nested( mock.patch.object(self.conn._session, '_wait_for_task', new=fake_wait_for_task), mock.patch.object(self.conn._session, '_call_method', @@ -1008,7 +1007,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): self.task_ref = task_ref return task_ref - with contextlib.nested( + with test.nested( mock.patch.object(self.conn._session, '_wait_for_task', fake_wait_for_task), mock.patch.object(self.conn._session, '_call_method', @@ -1038,7 +1037,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): self.task_ref = task_ref return task_ref - with contextlib.nested( + with test.nested( mock.patch.object(self.conn._session, '_wait_for_task', fake_wait_for_task), mock.patch.object(self.conn._session, '_call_method', @@ -1069,7 +1068,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): self.task_ref = task_ref return task_ref - with contextlib.nested( + with test.nested( mock.patch.object(self.conn._session, '_wait_for_task', fake_wait_for_task), mock.patch.object(self.conn._session, '_call_method', @@ -1285,7 +1284,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): value="Snapshot-123", name="VirtualMachineSnapshot") - with contextlib.nested( + with test.nested( mock.patch.object(self.conn._session, '_wait_for_task', side_effect=exception), mock.patch.object(vmops, '_time_sleep_wrapper') @@ -1447,7 +1446,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): def test_resume_state_on_host_boot_no_reboot(self): self._create_instance() for state in ['poweredOn', 'suspended']: - with contextlib.nested( + with test.nested( mock.patch.object(driver.VMwareVCDriver, 'reboot'), mock.patch.object(vm_util, 'get_vm_state', return_value=state) @@ -1510,7 +1509,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): return 'fake-ref' self._create_instance() - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_vm_ref_from_name', fake_vm_ref_from_name), mock.patch.object(self.conn._session, @@ -1709,7 +1708,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): device = mock.Mock(backing=backing) vmdk_info = vm_util.VmdkInfo('fake-path', adapter_type, disk_type, 64, device) - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_vm_ref', return_value=mock.sentinel.vm_ref), mock.patch.object(volumeops.VMwareVolumeOps, '_get_volume_ref'), diff --git a/nova/tests/unit/virt/vmwareapi/test_ds_util.py b/nova/tests/unit/virt/vmwareapi/test_ds_util.py index efbcf193c16d..e56e3c28f8ab 100644 --- a/nova/tests/unit/virt/vmwareapi/test_ds_util.py +++ b/nova/tests/unit/virt/vmwareapi/test_ds_util.py @@ -12,7 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib import re import mock @@ -46,7 +45,7 @@ class DsUtilTestCase(test.NoDBTestCase): self.assertEqual('fake-dc-ref', datacenter) return 'fake_delete_task' - with contextlib.nested( + with test.nested( mock.patch.object(self.session, '_wait_for_task'), mock.patch.object(self.session, '_call_method', fake_call_method) @@ -70,7 +69,7 @@ class DsUtilTestCase(test.NoDBTestCase): self.assertEqual('fake-dst-dc-ref', dst_dc_ref) return 'fake_copy_task' - with contextlib.nested( + with test.nested( mock.patch.object(self.session, '_wait_for_task'), mock.patch.object(self.session, '_call_method', fake_call_method) @@ -96,7 +95,7 @@ class DsUtilTestCase(test.NoDBTestCase): self.assertEqual('fake-dc-ref', destinationDatacenter) return 'fake_move_task' - with contextlib.nested( + with test.nested( mock.patch.object(self.session, '_wait_for_task'), mock.patch.object(self.session, '_call_method', fake_call_method) @@ -121,7 +120,7 @@ class DsUtilTestCase(test.NoDBTestCase): self.assertEqual('fake-dc-ref', dest_datacenter) return 'fake_move_task' - with contextlib.nested( + with test.nested( mock.patch.object(self.session, '_wait_for_task'), mock.patch.object(self.session, '_call_method', fake_call_method) @@ -132,7 +131,7 @@ class DsUtilTestCase(test.NoDBTestCase): mock.call('fake_move_task')]) def test_disk_copy(self): - with contextlib.nested( + with test.nested( mock.patch.object(self.session, '_wait_for_task'), mock.patch.object(self.session, '_call_method', return_value=mock.sentinel.cm) @@ -148,7 +147,7 @@ class DsUtilTestCase(test.NoDBTestCase): destName='sentinel.dest_ds') def test_disk_delete(self): - with contextlib.nested( + with test.nested( mock.patch.object(self.session, '_wait_for_task'), mock.patch.object(self.session, '_call_method', return_value=mock.sentinel.cm) @@ -204,7 +203,7 @@ class DsUtilTestCase(test.NoDBTestCase): # Should never get here self.fail() - with contextlib.nested( + with test.nested( mock.patch.object(self.session, '_call_method', fake_call_method), mock.patch.object(self.session, '_wait_for_task', @@ -229,7 +228,7 @@ class DsUtilTestCase(test.NoDBTestCase): # Should never get here self.fail() - with contextlib.nested( + with test.nested( mock.patch.object(self.session, '_call_method', fake_call_method), mock.patch.object(self.session, '_wait_for_task', diff --git a/nova/tests/unit/virt/vmwareapi/test_imagecache.py b/nova/tests/unit/virt/vmwareapi/test_imagecache.py index 35e6271dc5bf..efdc65d7a16f 100644 --- a/nova/tests/unit/virt/vmwareapi/test_imagecache.py +++ b/nova/tests/unit/virt/vmwareapi/test_imagecache.py @@ -12,7 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib import datetime import mock @@ -59,7 +58,7 @@ class ImageCacheManagerTestCase(test.NoDBTestCase): fmt=imagecache.TIMESTAMP_FORMAT)) return ts - with contextlib.nested( + with test.nested( mock.patch.object(self._imagecache, '_get_timestamp', fake_get_timestamp), mock.patch.object(ds_util, 'file_delete') @@ -87,10 +86,8 @@ class ImageCacheManagerTestCase(test.NoDBTestCase): files.add(self._file_name) return files - with contextlib.nested( - mock.patch.object(ds_util, 'get_sub_folders', - fake_get_sub_folders) - ): + with mock.patch.object(ds_util, 'get_sub_folders', + fake_get_sub_folders): self.exists = True ts = self._imagecache._get_timestamp( 'fake-ds-browser', @@ -132,7 +129,7 @@ class ImageCacheManagerTestCase(test.NoDBTestCase): files.add('image-ref-uuid') return files - with contextlib.nested( + with test.nested( mock.patch.object(vutil, 'get_object_property', fake_get_object_property), mock.patch.object(ds_util, 'get_sub_folders', @@ -208,7 +205,7 @@ class ImageCacheManagerTestCase(test.NoDBTestCase): def fake_timestamp_cleanup(dc_ref, ds_browser, ds_path): self.assertEqual('[fake-ds] fake-path/fake-image-4', str(ds_path)) - with contextlib.nested( + with test.nested( mock.patch.object(self._imagecache, '_get_ds_browser', fake_get_ds_browser), mock.patch.object(self._imagecache, '_get_timestamp', @@ -249,7 +246,7 @@ class ImageCacheManagerTestCase(test.NoDBTestCase): self.assertEqual(self.images, self._imagecache.originals) - with contextlib.nested( + with test.nested( mock.patch.object(self._imagecache, '_list_datastore_images', fake_list_datastore_images), mock.patch.object(self._imagecache, diff --git a/nova/tests/unit/virt/vmwareapi/test_images.py b/nova/tests/unit/virt/vmwareapi/test_images.py index 72a870af64e7..9e3a5b1b2bc1 100644 --- a/nova/tests/unit/virt/vmwareapi/test_images.py +++ b/nova/tests/unit/virt/vmwareapi/test_images.py @@ -15,7 +15,6 @@ Test suite for images. """ -import contextlib import os import tarfile @@ -63,7 +62,7 @@ class VMwareImagesTestCase(test.NoDBTestCase): file_path, file_size): return write_file_handle - with contextlib.nested( + with test.nested( mock.patch.object(rw_handles, 'ImageReadHandle', side_effect=fake_read_handle), mock.patch.object(rw_handles, 'FileWriteHandle', @@ -114,7 +113,7 @@ class VMwareImagesTestCase(test.NoDBTestCase): with open(ovf_path) as f: ovf_descriptor = f.read() - with contextlib.nested( + with test.nested( mock.patch.object(images.IMAGE_API, 'get'), mock.patch.object(images.IMAGE_API, 'download'), mock.patch.object(images, 'start_transfer'), @@ -182,7 +181,7 @@ class VMwareImagesTestCase(test.NoDBTestCase): """Test fetching streamOptimized disk image.""" session = mock.MagicMock() - with contextlib.nested( + with test.nested( mock.patch.object(images.IMAGE_API, 'get'), mock.patch.object(images.IMAGE_API, 'download'), mock.patch.object(images, 'start_transfer'), diff --git a/nova/tests/unit/virt/vmwareapi/test_vif.py b/nova/tests/unit/virt/vmwareapi/test_vif.py index 78a7aacdf4b5..d48c95f00c79 100644 --- a/nova/tests/unit/virt/vmwareapi/test_vif.py +++ b/nova/tests/unit/virt/vmwareapi/test_vif.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib - import mock from oslo_config import cfg from oslo_vmware import exceptions as vexc @@ -279,7 +277,7 @@ class VMwareVifTestCase(test.NoDBTestCase): if method == 'AddPortGroup': raise vexc.AlreadyExistsException() - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_add_vswitch_port_group_spec'), mock.patch.object(vm_util, 'get_host_ref'), mock.patch.object(self.session, '_call_method', @@ -294,7 +292,7 @@ class VMwareVifTestCase(test.NoDBTestCase): if method == 'AddPortGroup': raise vexc.VMwareDriverException() - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_add_vswitch_port_group_spec'), mock.patch.object(vm_util, 'get_host_ref'), mock.patch.object(self.session, '_call_method', @@ -311,7 +309,7 @@ class VMwareVifTestCase(test.NoDBTestCase): if method == 'get_object_property': raise vexc.InvalidPropertyException() - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_host_ref'), mock.patch.object(self.session, '_call_method', fake_call_method), diff --git a/nova/tests/unit/virt/vmwareapi/test_vm_util.py b/nova/tests/unit/virt/vmwareapi/test_vm_util.py index d4930965c297..72f78c334946 100644 --- a/nova/tests/unit/virt/vmwareapi/test_vm_util.py +++ b/nova/tests/unit/virt/vmwareapi/test_vm_util.py @@ -15,7 +15,6 @@ # under the License. import collections -import contextlib import mock from oslo_utils import uuidutils @@ -824,7 +823,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): session = fake.FakeSession() fake_call_mock = mock.Mock(side_effect=fake_call_method) fake_wait_mock = mock.Mock(side_effect=fake_wait_for_task) - with contextlib.nested( + with test.nested( mock.patch.object(session, '_wait_for_task', fake_wait_mock), mock.patch.object(session, '_call_method', @@ -889,7 +888,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): def test_power_on_instance_with_vm_ref(self): session = fake.FakeSession() - with contextlib.nested( + with test.nested( mock.patch.object(session, "_call_method", return_value='fake-task'), mock.patch.object(session, "_wait_for_task"), @@ -903,7 +902,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): def test_power_on_instance_without_vm_ref(self): session = fake.FakeSession() - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, "get_vm_ref", return_value='fake-vm-ref'), mock.patch.object(session, "_call_method", @@ -919,7 +918,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): def test_power_on_instance_with_exception(self): session = fake.FakeSession() - with contextlib.nested( + with test.nested( mock.patch.object(session, "_call_method", return_value='fake-task'), mock.patch.object(session, "_wait_for_task", @@ -936,7 +935,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): def test_power_on_instance_with_power_state_exception(self): session = fake.FakeSession() - with contextlib.nested( + with test.nested( mock.patch.object(session, "_call_method", return_value='fake-task'), mock.patch.object( @@ -953,7 +952,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): def test_create_virtual_disk(self): session = fake.FakeSession() dm = session.vim.service_content.virtualDiskManager - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, "get_vmdk_create_spec", return_value='fake-spec'), mock.patch.object(session, "_call_method", @@ -979,7 +978,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): def test_copy_virtual_disk(self): session = fake.FakeSession() dm = session.vim.service_content.virtualDiskManager - with contextlib.nested( + with test.nested( mock.patch.object(session, "_call_method", return_value='fake-task'), mock.patch.object(session, "_wait_for_task"), @@ -1002,7 +1001,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): def test_reconfigure_vm(self): session = fake.FakeSession() - with contextlib.nested( + with test.nested( mock.patch.object(session, '_call_method', return_value='fake_reconfigure_task'), mock.patch.object(session, '_wait_for_task') @@ -1127,7 +1126,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): @mock.patch.object(vm_util, "get_vm_ref") def test_power_off_instance(self, fake_get_ref): session = fake.FakeSession() - with contextlib.nested( + with test.nested( mock.patch.object(session, '_call_method', return_value='fake-task'), mock.patch.object(session, '_wait_for_task') @@ -1142,7 +1141,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): @mock.patch.object(vm_util, "get_vm_ref", return_value="fake-vm-ref") def test_power_off_instance_no_vm_ref(self, fake_get_ref): session = fake.FakeSession() - with contextlib.nested( + with test.nested( mock.patch.object(session, '_call_method', return_value='fake-task'), mock.patch.object(session, '_wait_for_task') @@ -1157,7 +1156,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): @mock.patch.object(vm_util, "get_vm_ref") def test_power_off_instance_with_exception(self, fake_get_ref): session = fake.FakeSession() - with contextlib.nested( + with test.nested( mock.patch.object(session, '_call_method', return_value='fake-task'), mock.patch.object(session, '_wait_for_task', @@ -1175,7 +1174,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase): @mock.patch.object(vm_util, "get_vm_ref") def test_power_off_instance_power_state_exception(self, fake_get_ref): session = fake.FakeSession() - with contextlib.nested( + with test.nested( mock.patch.object(session, '_call_method', return_value='fake-task'), mock.patch.object( diff --git a/nova/tests/unit/virt/vmwareapi/test_vmops.py b/nova/tests/unit/virt/vmwareapi/test_vmops.py index ee77ad1a8514..ef7e80d02845 100644 --- a/nova/tests/unit/virt/vmwareapi/test_vmops.py +++ b/nova/tests/unit/virt/vmwareapi/test_vmops.py @@ -12,7 +12,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import contextlib import mock from oslo_serialization import jsonutils @@ -239,7 +238,7 @@ class VMwareVMOpsTestCase(test.NoDBTestCase): self.assertTrue(kwargs['consolidate']) return 'fake_remove_snapshot_task' - with contextlib.nested( + with test.nested( mock.patch.object(self._session, '_wait_for_task'), mock.patch.object(self._session, '_call_method', fake_call_method) ) as (_wait_for_task, _call_method): @@ -266,7 +265,7 @@ class VMwareVMOpsTestCase(test.NoDBTestCase): self.assertEqual(('fake_snapshot_task', 'info'), args) return task_info - with contextlib.nested( + with test.nested( mock.patch.object(self._session, '_wait_for_task'), mock.patch.object(self._session, '_call_method', fake_call_method) ) as (_wait_for_task, _call_method): @@ -438,7 +437,7 @@ class VMwareVMOpsTestCase(test.NoDBTestCase): 'fake-capacity', device) - with contextlib.nested( + with test.nested( mock.patch.object(self._vmops, 'get_datacenter_ref_and_name'), mock.patch.object(vm_util, 'get_vmdk_info', return_value=vmdk) @@ -485,7 +484,7 @@ class VMwareVMOpsTestCase(test.NoDBTestCase): self.assertEqual('get_object_property', method) self.assertEqual(expected_args, args) - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'power_on_instance'), mock.patch.object(vm_util, 'find_rescue_device'), mock.patch.object(vm_util, 'get_vm_ref', return_value=vm_ref), @@ -509,7 +508,7 @@ class VMwareVMOpsTestCase(test.NoDBTestCase): vm_ref, self._instance, mock.ANY, destroy_disk=True) def _test_finish_migration(self, power_on=True, resize_instance=False): - with contextlib.nested( + with test.nested( mock.patch.object(self._vmops, '_resize_create_ephemerals_and_swap'), mock.patch.object(self._vmops, "_update_instance_progress"), @@ -592,7 +591,7 @@ class VMwareVMOpsTestCase(test.NoDBTestCase): vmFolder='fake_folder') extra_specs = vm_util.ExtraSpecs() fake_get_extra_specs.return_value = extra_specs - with contextlib.nested( + with test.nested( mock.patch.object(self._vmops, 'get_datacenter_ref_and_name', return_value=dc_info), mock.patch.object(vm_util, 'get_vmdk_info', @@ -779,7 +778,7 @@ class VMwareVMOpsTestCase(test.NoDBTestCase): device) dc_info = ds_util.DcInfo(ref='fake_ref', name='fake', vmFolder='fake_folder') - with contextlib.nested( + with test.nested( mock.patch.object(self._vmops, 'get_datacenter_ref_and_name', return_value=dc_info), mock.patch.object(vm_util, 'get_vmdk_info', @@ -1352,7 +1351,7 @@ class VMwareVMOpsTestCase(test.NoDBTestCase): if extra_specs is None: extra_specs = vm_util.ExtraSpecs() - with contextlib.nested( + with test.nested( mock.patch.object(self._session, '_wait_for_task'), mock.patch.object(self._session, '_call_method', mock_call_method), @@ -1994,9 +1993,7 @@ class VMwareVMOpsTestCase(test.NoDBTestCase): return ticket elif method == 'get_object_property': return 'fira-host' - with contextlib.nested( - mock.patch.object(self._session, 'invoke_api', fake_invoke), - ): + with mock.patch.object(self._session, 'invoke_api', fake_invoke): result = self._vmops._get_esx_host_and_cookies(datastore, 'ha-datacenter', file_path) @@ -2266,7 +2263,7 @@ class VMwareVMOpsTestCase(test.NoDBTestCase): elif (expected_method == 'ResetVM_Task'): return 'fake-task' - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, "get_vm_ref", return_value='fake-vm-ref'), mock.patch.object(self._session, "_call_method", diff --git a/nova/tests/unit/virt/vmwareapi/test_volumeops.py b/nova/tests/unit/virt/vmwareapi/test_volumeops.py index 428528cebd87..81a2e6f884bd 100644 --- a/nova/tests/unit/virt/vmwareapi/test_volumeops.py +++ b/nova/tests/unit/virt/vmwareapi/test_volumeops.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import contextlib - import mock from oslo_vmware import exceptions as oslo_vmw_exceptions from oslo_vmware import vim_util as vutil @@ -71,7 +69,7 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase): self.assertFalse(hasattr(virtual_device_config, 'fileOperation')) return 'fake_configure_task' - with contextlib.nested( + with test.nested( mock.patch.object(self._session, '_wait_for_task'), mock.patch.object(self._session, '_call_method', fake_call_method) @@ -127,7 +125,7 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase): vmdk_info = vm_util.VmdkInfo('fake-path', constants.ADAPTER_TYPE_IDE, constants.DISK_TYPE_PREALLOCATED, 1024, 'fake-device') - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_vm_ref'), mock.patch.object(self._volumeops, '_get_volume_ref'), mock.patch.object(vm_util, 'get_vmdk_info', @@ -164,7 +162,7 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase): vmdk_info = vm_util.VmdkInfo('fake-path', 'lsiLogic', 'thin', 1024, 'fake-device') - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_vm_ref', return_value=mock.sentinel.vm_ref), mock.patch.object(self._volumeops, '_get_volume_ref', @@ -218,7 +216,7 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase): vmdk_info = vm_util.VmdkInfo('fake-path', constants.ADAPTER_TYPE_IDE, constants.DISK_TYPE_PREALLOCATED, 1024, 'fake-device') - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_vm_ref', return_value=mock.sentinel.vm_ref), mock.patch.object(self._volumeops, '_get_volume_ref'), @@ -258,7 +256,7 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase): device) adapter_type = adapter_type or default_adapter_type - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_vm_ref', return_value=vm_ref), mock.patch.object(self._volumeops, '_get_volume_ref'), mock.patch.object(vm_util, 'get_vmdk_info', @@ -290,7 +288,7 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase): default_adapter_type = constants.DEFAULT_ADAPTER_TYPE adapter_type = adapter_type or default_adapter_type - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_vm_ref', return_value=vm_ref), mock.patch.object(self._volumeops, '_iscsi_discover_target', return_value=(mock.sentinel.device_name, @@ -448,7 +446,7 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase): hba = vmwareapi_fake.HostInternetScsiHba(iqn) hbas = mock.MagicMock(HostHostBusAdapter=[hba]) - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_host_ref_for_vm', return_value=host_mor), mock.patch.object(self._volumeops._session, '_call_method', @@ -471,7 +469,7 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase): hba = vmwareapi_fake.HostInternetScsiHba(iqn) hbas = mock.MagicMock(HostHostBusAdapter=[hba]) - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_host_ref_for_vm', side_effect=exception.InstanceNotFound('fake')), mock.patch.object(vm_util, 'get_host_ref', @@ -501,7 +499,7 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase): url = 'test_url' self.flags(host_ip=url, group='vmware') - with contextlib.nested( + with test.nested( mock.patch.object(vm_util, 'get_vm_ref', return_value=vm_ref), mock.patch.object(self._volumeops, '_iscsi_get_host_iqn', return_value=iqn) diff --git a/tests-py3.txt b/tests-py3.txt index 4a160f179056..92609e59fdb8 100644 --- a/tests-py3.txt +++ b/tests-py3.txt @@ -156,7 +156,6 @@ nova.tests.unit.cells.test_cells_scheduler.CellsSchedulerTestCase nova.tests.unit.cells.test_cells_state_manager.TestCellsGetCapacity nova.tests.unit.cells.test_cells_state_manager.TestCellsStateManager nova.tests.unit.cells.test_cells_state_manager.TestCellsStateManagerNToOne -nova.tests.unit.cert.test_rpcapi.CertRpcAPITestCase nova.tests.unit.cmd.test_baseproxy.BaseProxyTestCase nova.tests.unit.compute.test_compute.ComputeAPIAggrCallsSchedulerTestCase nova.tests.unit.compute.test_compute.ComputeAPITestCase @@ -180,9 +179,7 @@ nova.tests.unit.compute.test_compute_mgr.ComputeManagerUnitTestCase nova.tests.unit.compute.test_compute_utils.UsageInfoTestCase nova.tests.unit.compute.test_compute_xen.ComputeXenTestCase nova.tests.unit.compute.test_host_api.ComputeHostAPICellsTestCase -nova.tests.unit.compute.test_host_api.ComputeHostAPITestCase nova.tests.unit.compute.test_resources.BaseTestCase -nova.tests.unit.compute.test_rpcapi.ComputeRpcAPITestCase nova.tests.unit.compute.test_shelve.ShelveComputeManagerTestCase nova.tests.unit.compute.test_tracker.TestInitComputeNode nova.tests.unit.compute.test_tracker.TestInstanceClaim @@ -194,10 +191,8 @@ nova.tests.unit.conductor.test_conductor.ConductorTaskAPITestCase nova.tests.unit.conductor.test_conductor.ConductorTaskRPCAPITestCase nova.tests.unit.conductor.test_conductor.ConductorTaskTestCase nova.tests.unit.conductor.test_conductor.ConductorTestCase -nova.tests.unit.console.test_rpcapi.ConsoleRpcAPITestCase nova.tests.unit.console.test_websocketproxy.NovaProxyRequestHandlerBaseTestCase nova.tests.unit.consoleauth.test_consoleauth.ControlauthMemcacheEncodingTestCase -nova.tests.unit.consoleauth.test_rpcapi.ConsoleAuthRpcAPITestCase nova.tests.unit.db.test_migrations.TestNovaMigrationsMySQL nova.tests.unit.db.test_migrations.TestNovaMigrationsPostgreSQL nova.tests.unit.db.test_migrations.TestNovaMigrationsSQLite @@ -219,7 +214,6 @@ nova.tests.unit.network.test_manager.FloatingIPTestCase nova.tests.unit.network.test_manager.LdapDNSTestCase nova.tests.unit.network.test_manager.VlanNetworkTestCase nova.tests.unit.network.test_neutronv2.TestNeutronv2WithMock -nova.tests.unit.network.test_rpcapi.NetworkRpcAPITestCase nova.tests.unit.pci.test_manager.PciDevTrackerTestCase nova.tests.unit.pci.test_stats.PciDeviceStatsTestCase nova.tests.unit.pci.test_stats.PciDeviceStatsWithTagsTestCase @@ -346,7 +340,6 @@ nova.tests.unit.virt.vmwareapi.test_imagecache.ImageCacheManagerTestCase nova.tests.unit.virt.vmwareapi.test_images.VMwareImagesTestCase nova.tests.unit.virt.vmwareapi.test_network_util.GetNetworkWithTheNameTestCase nova.tests.unit.virt.vmwareapi.test_read_write_util.ReadWriteUtilTestCase -nova.tests.unit.virt.vmwareapi.test_vif.VMwareVifTestCase nova.tests.unit.virt.vmwareapi.test_vim_util.VMwareVIMUtilTestCase nova.tests.unit.virt.vmwareapi.test_vm_util.VMwareVMUtilGetHostRefTestCase nova.tests.unit.virt.vmwareapi.test_vm_util.VMwareVMUtilTestCase