From 3196cef6986b733ff0a101164e5f3a49a10425c0 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Wed, 12 Mar 2014 02:13:30 +0000 Subject: [PATCH] Removes calls to mock.patch.stopall in unit tests Removes unnecessary calls to mock.patch.stopall in individual unit tests since it is now automatically called from the base test case. Closes-Bug: #1291130 Change-Id: Ia8e82d6a9a9bc9bd5f48146c1be53069ff1cdb01 --- neutron/tests/unit/bigswitch/test_base.py | 1 - .../unit/bigswitch/test_restproxy_agent.py | 1 - .../tests/unit/cisco/test_network_plugin.py | 1 - neutron/tests/unit/cisco/test_nexus_plugin.py | 1 - .../db/loadbalancer/test_db_loadbalancer.py | 1 - .../test_hyperv_security_groups_driver.py | 1 - .../linuxbridge/test_lb_security_group.py | 1 - .../drivers/cisco/nexus/test_cisco_mech.py | 1 - .../drivers/cisco/nexus/test_cisco_nexus.py | 1 - .../unit/ml2/drivers/test_l2population.py | 1 - neutron/tests/unit/ml2/test_security_group.py | 1 - .../unit/mlnx/test_mlnx_neutron_agent.py | 1 - .../unit/mlnx/test_mlnx_security_group.py | 1 - .../tests/unit/nec/test_agent_scheduler.py | 6 ++---- neutron/tests/unit/nec/test_nec_agent.py | 1 - neutron/tests/unit/nec/test_nec_plugin.py | 19 +++---------------- neutron/tests/unit/nec/test_ofc_manager.py | 1 - neutron/tests/unit/nec/test_pfc_driver.py | 1 - neutron/tests/unit/nec/test_router.py | 1 - neutron/tests/unit/nec/test_security_group.py | 1 - neutron/tests/unit/nec/test_trema_driver.py | 1 - .../unit/ofagent/test_ofa_neutron_agent.py | 1 - .../unit/oneconvergence/test_nvsd_agent.py | 1 - .../unit/oneconvergence/test_nvsd_plugin.py | 3 --- .../oneconvergence/test_security_group.py | 2 -- .../tests/unit/openvswitch/test_ovs_lib.py | 1 - .../openvswitch/test_ovs_neutron_agent.py | 2 -- .../openvswitch/test_ovs_security_group.py | 1 - .../tests/unit/openvswitch/test_ovs_tunnel.py | 1 - neutron/tests/unit/ryu/test_ryu_agent.py | 1 - .../tests/unit/ryu/test_ryu_security_group.py | 1 - .../l3reference/test_firewall_l3_agent.py | 1 - .../agents/test_firewall_agent_api.py | 1 - .../agents/varmour/test_varmour_router.py | 2 -- .../drivers/varmour/test_varmour_fwaas.py | 2 -- .../services/firewall/test_fwaas_plugin.py | 1 - .../loadbalancer/agent/test_agent_manager.py | 1 - .../services/loadbalancer/agent/test_api.py | 1 - .../drivers/haproxy/test_namespace_driver.py | 1 - .../drivers/netscaler/test_ncc_client.py | 1 - .../netscaler/test_netscaler_driver.py | 1 - .../drivers/radware/test_plugin_driver.py | 1 - .../drivers/test_agent_driver_base.py | 6 ------ .../services/metering/test_metering_agent.py | 4 ---- .../services/metering/test_metering_plugin.py | 4 ---- .../vpn/device_drivers/test_cisco_ipsec.py | 7 ------- .../services/vpn/device_drivers/test_ipsec.py | 1 - .../vpn/service_drivers/test_cisco_ipsec.py | 3 --- .../vpn/service_drivers/test_ipsec.py | 1 - .../tests/unit/services/vpn/test_vpn_agent.py | 1 - .../services/vpn/test_vpnaas_driver_plugin.py | 1 - neutron/tests/unit/test_api_v2_extension.py | 1 - neutron/tests/unit/test_debug_commands.py | 1 - neutron/tests/unit/test_dhcp_agent.py | 1 - neutron/tests/unit/test_iptables_manager.py | 1 - neutron/tests/unit/test_l3_agent.py | 3 --- neutron/tests/unit/test_linux_dhcp.py | 1 - neutron/tests/unit/test_linux_interface.py | 1 - neutron/tests/unit/test_metadata_agent.py | 1 - .../tests/unit/test_security_groups_rpc.py | 2 -- .../unit/vmware/extensions/test_networkgw.py | 1 - neutron/tests/unit/vmware/test_nsx_plugin.py | 1 - neutron/tests/unit/vmware/test_nsx_utils.py | 5 ----- .../unit/vmware/vshield/test_edge_router.py | 1 - 64 files changed, 5 insertions(+), 114 deletions(-) diff --git a/neutron/tests/unit/bigswitch/test_base.py b/neutron/tests/unit/bigswitch/test_base.py index a8eec715d13..867b7eefb54 100644 --- a/neutron/tests/unit/bigswitch/test_base.py +++ b/neutron/tests/unit/bigswitch/test_base.py @@ -59,7 +59,6 @@ class BigSwitchTestBase(object): self.callbacks_p = mock.patch(CALLBACKS) self.spawn_p = mock.patch(SPAWN) self.watch_p = mock.patch(CWATCH) - self.addCleanup(mock.patch.stopall) self.addCleanup(db.clear_db) self.callbacks_p.start() self.plugin_notifier_p.start() diff --git a/neutron/tests/unit/bigswitch/test_restproxy_agent.py b/neutron/tests/unit/bigswitch/test_restproxy_agent.py index 385683ffe14..5a5ee438eb7 100644 --- a/neutron/tests/unit/bigswitch/test_restproxy_agent.py +++ b/neutron/tests/unit/bigswitch/test_restproxy_agent.py @@ -37,7 +37,6 @@ class BaseAgentTestCase(base.BaseTestCase): def setUp(self): super(BaseAgentTestCase, self).setUp() - self.addCleanup(mock.patch.stopall) self.mod_agent = importutils.import_module(AGENTMOD) diff --git a/neutron/tests/unit/cisco/test_network_plugin.py b/neutron/tests/unit/cisco/test_network_plugin.py index 21659694f70..23f4f41c262 100644 --- a/neutron/tests/unit/cisco/test_network_plugin.py +++ b/neutron/tests/unit/cisco/test_network_plugin.py @@ -132,7 +132,6 @@ class CiscoNetworkPluginV2TestCase(test_db_plugin.NeutronDbPluginV2TestCase): # Used for SVI placement when round-robin placement is disabled. mock.patch.object(cisco_config, 'first_device_ip', new=NEXUS_IP_ADDR).start() - self.addCleanup(mock.patch.stopall) def _get_plugin_ref(self): return getattr(NeutronManager.get_plugin(), diff --git a/neutron/tests/unit/cisco/test_nexus_plugin.py b/neutron/tests/unit/cisco/test_nexus_plugin.py index 6a959d6095c..3379cb84248 100644 --- a/neutron/tests/unit/cisco/test_nexus_plugin.py +++ b/neutron/tests/unit/cisco/test_nexus_plugin.py @@ -161,7 +161,6 @@ class TestCiscoNexusPlugin(base.BaseTestCase): # according to the preceding switch config. mock.patch.object(cisco_config, 'first_device_ip', new=NEXUS_IP_ADDRESS).start() - self.addCleanup(mock.patch.stopall) def test_create_delete_networks(self): """Tests creation of two new Virtual Networks.""" diff --git a/neutron/tests/unit/db/loadbalancer/test_db_loadbalancer.py b/neutron/tests/unit/db/loadbalancer/test_db_loadbalancer.py index 691b9615697..bda949f5184 100644 --- a/neutron/tests/unit/db/loadbalancer/test_db_loadbalancer.py +++ b/neutron/tests/unit/db/loadbalancer/test_db_loadbalancer.py @@ -352,7 +352,6 @@ class LoadBalancerPluginDbTestCase(LoadBalancerTestMixin, mock_lbaas_agent = mock.MagicMock() get_lbaas_agent_patcher.start().return_value = mock_lbaas_agent mock_lbaas_agent.__getitem__.return_value = {'host': 'host'} - self.addCleanup(mock.patch.stopall) self.addCleanup(cfg.CONF.reset) self._subnet_id = _subnet_id diff --git a/neutron/tests/unit/hyperv/test_hyperv_security_groups_driver.py b/neutron/tests/unit/hyperv/test_hyperv_security_groups_driver.py index 1ac5b316321..1411cfa3c42 100644 --- a/neutron/tests/unit/hyperv/test_hyperv_security_groups_driver.py +++ b/neutron/tests/unit/hyperv/test_hyperv_security_groups_driver.py @@ -48,7 +48,6 @@ class TestHyperVSecurityGroupsDriver(base.BaseTestCase): self._mock_windows_version = mock.patch.object(utilsfactory, 'get_hypervutils') self._mock_windows_version.start() - self.addCleanup(mock.patch.stopall) self._driver = sg_driver.HyperVSecurityGroupsDriver() self._driver._utils = mock.MagicMock() diff --git a/neutron/tests/unit/linuxbridge/test_lb_security_group.py b/neutron/tests/unit/linuxbridge/test_lb_security_group.py index 9406a120ba6..62662036a32 100644 --- a/neutron/tests/unit/linuxbridge/test_lb_security_group.py +++ b/neutron/tests/unit/linuxbridge/test_lb_security_group.py @@ -45,7 +45,6 @@ class LinuxBridgeSecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase): RESOURCE_ATTRIBUTE_MAP[item]. copy()) super(LinuxBridgeSecurityGroupsTestCase, self).setUp(PLUGIN_NAME) - self.addCleanup(mock.patch.stopall) def tearDown(self): attributes.RESOURCE_ATTRIBUTE_MAP = self._attribute_map_bk_ diff --git a/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_mech.py b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_mech.py index e90333634aa..e35cd9b0d29 100644 --- a/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_mech.py +++ b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_mech.py @@ -64,7 +64,6 @@ class CiscoML2MechanismTestCase(test_db_plugin.NeutronDbPluginV2TestCase): driver """ - self.addCleanup(mock.patch.stopall) # Configure the ML2 mechanism drivers and network types ml2_opts = { diff --git a/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus.py b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus.py index 675daed7a85..dfa74c07f7f 100644 --- a/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus.py +++ b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus.py @@ -167,7 +167,6 @@ class TestCiscoNexusDevice(base.BaseTestCase): self._cisco_mech_driver = (mech_cisco_nexus. CiscoNexusMechanismDriver()) - self.addCleanup(mock.patch.stopall) self.addCleanup(db.clear_db) def _create_delete_port(self, port_config): diff --git a/neutron/tests/unit/ml2/drivers/test_l2population.py b/neutron/tests/unit/ml2/drivers/test_l2population.py index 352405ad0c9..2698b3db371 100644 --- a/neutron/tests/unit/ml2/drivers/test_l2population.py +++ b/neutron/tests/unit/ml2/drivers/test_l2population.py @@ -120,7 +120,6 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase): uptime_patch = mock.patch(uptime, return_value=190) uptime_patch.start() - self.addCleanup(mock.patch.stopall) self.addCleanup(db_api.clear_db) def tearDown(self): diff --git a/neutron/tests/unit/ml2/test_security_group.py b/neutron/tests/unit/ml2/test_security_group.py index 34d71a71efe..b0a06fa8219 100644 --- a/neutron/tests/unit/ml2/test_security_group.py +++ b/neutron/tests/unit/ml2/test_security_group.py @@ -31,7 +31,6 @@ class Ml2SecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase): def setUp(self, plugin=None): test_sg_rpc.set_firewall_driver(test_sg_rpc.FIREWALL_HYBRID_DRIVER) - self.addCleanup(mock.patch.stopall) notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() self.notifier = mock.Mock() diff --git a/neutron/tests/unit/mlnx/test_mlnx_neutron_agent.py b/neutron/tests/unit/mlnx/test_mlnx_neutron_agent.py index a78cc42e4ba..ace306c93e1 100644 --- a/neutron/tests/unit/mlnx/test_mlnx_neutron_agent.py +++ b/neutron/tests/unit/mlnx/test_mlnx_neutron_agent.py @@ -29,7 +29,6 @@ class TestEswitchAgent(base.BaseTestCase): def setUp(self): super(TestEswitchAgent, self).setUp() - self.addCleanup(mock.patch.stopall) # Avoid rpc initialization for unit tests cfg.CONF.set_override('rpc_backend', 'neutron.openstack.common.rpc.impl_fake') diff --git a/neutron/tests/unit/mlnx/test_mlnx_security_group.py b/neutron/tests/unit/mlnx/test_mlnx_security_group.py index 9613404196a..347de62c878 100644 --- a/neutron/tests/unit/mlnx/test_mlnx_security_group.py +++ b/neutron/tests/unit/mlnx/test_mlnx_security_group.py @@ -44,7 +44,6 @@ class MlnxSecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase): RESOURCE_ATTRIBUTE_MAP[item]. copy()) super(MlnxSecurityGroupsTestCase, self).setUp(PLUGIN_NAME) - self.addCleanup(mock.patch.stopall) def tearDown(self): attributes.RESOURCE_ATTRIBUTE_MAP = self._attribute_map_bk_ diff --git a/neutron/tests/unit/nec/test_agent_scheduler.py b/neutron/tests/unit/nec/test_agent_scheduler.py index 8793986161a..60c1770a5a7 100644 --- a/neutron/tests/unit/nec/test_agent_scheduler.py +++ b/neutron/tests/unit/nec/test_agent_scheduler.py @@ -45,8 +45,7 @@ class NecDhcpAgentNotifierTestCase( plugin_str = test_nec_plugin.PLUGIN_NAME def setUp(self): - # OvsDhcpAgentNotifierTestCase uses stop() for each mock. - self.setup_nec_plugin_base(use_stop_each=True) + self.setup_nec_plugin_base() super(NecDhcpAgentNotifierTestCase, self).setUp() @@ -58,8 +57,7 @@ class NecL3AgentNotifierTestCase( l3_plugin = None def setUp(self): - # OvsDhcpAgentNotifierTestCase uses stop() for each mock. - self.setup_nec_plugin_base(use_stop_each=True) + self.setup_nec_plugin_base() super(NecL3AgentNotifierTestCase, self).setUp() diff --git a/neutron/tests/unit/nec/test_nec_agent.py b/neutron/tests/unit/nec/test_nec_agent.py index 341eaf77498..2e45306159d 100644 --- a/neutron/tests/unit/nec/test_nec_agent.py +++ b/neutron/tests/unit/nec/test_nec_agent.py @@ -38,7 +38,6 @@ class TestNecAgentBase(base.BaseTestCase): def setUp(self): super(TestNecAgentBase, self).setUp() self.addCleanup(cfg.CONF.reset) - self.addCleanup(mock.patch.stopall) cfg.CONF.set_override('rpc_backend', 'neutron.openstack.common.rpc.impl_fake') cfg.CONF.set_override('host', 'dummy-host') diff --git a/neutron/tests/unit/nec/test_nec_plugin.py b/neutron/tests/unit/nec/test_nec_plugin.py index 78a0a7911ce..9aa470a304f 100644 --- a/neutron/tests/unit/nec/test_nec_plugin.py +++ b/neutron/tests/unit/nec/test_nec_plugin.py @@ -65,28 +65,16 @@ class NecPluginV2TestCaseBase(object): os.remove(self.nec_ini_file) self.nec_ini_file = None - def patch_remote_calls(self, use_stop=False): + def patch_remote_calls(self): self.plugin_notifier_p = mock.patch(NOTIFIER) self.ofc_manager_p = mock.patch(OFC_MANAGER) self.plugin_notifier_p.start() self.ofc_manager_p.start() - # When using mock.patch.stopall, we need to ensure - # stop is not used anywhere in a single test. - # In Neutron several tests use stop for each patched object, - # so we need to take care of both cases. - if use_stop: - self.addCleanup(self.plugin_notifier_p.stop) - self.addCleanup(self.ofc_manager_p.stop) - def setup_nec_plugin_base(self, use_stop_all=True, - use_stop_each=False): - # If use_stop_each is set, use_stop_all cannot be set. - if use_stop_all and not use_stop_each: - self.addCleanup(mock.patch.stopall) + def setup_nec_plugin_base(self): self._set_nec_ini() self.addCleanup(self._clean_nec_ini) - # kevinbenton: stopping patches is now handled in base test class - self.patch_remote_calls(use_stop=False) + self.patch_remote_calls() class NecPluginV2TestCase(NecPluginV2TestCaseBase, @@ -103,7 +91,6 @@ class NecPluginV2TestCase(NecPluginV2TestCaseBase, self.callback_nec.update_ports(self.context, **kwargs) def setUp(self, plugin=None, ext_mgr=None): - self.addCleanup(mock.patch.stopall) self._set_nec_ini() self.addCleanup(self._clean_nec_ini) diff --git a/neutron/tests/unit/nec/test_ofc_manager.py b/neutron/tests/unit/nec/test_ofc_manager.py index a163e738250..e4543c21f5b 100644 --- a/neutron/tests/unit/nec/test_ofc_manager.py +++ b/neutron/tests/unit/nec/test_ofc_manager.py @@ -55,7 +55,6 @@ class OFCManagerTestBase(base.BaseTestCase): # NOTE: enable_autocheck() is a feature of StubOFCDriver self.ofc.driver.enable_autocheck() self.ctx = context.get_admin_context() - self.addCleanup(mock.patch.stopall) def get_random_params(self): """create random parameters for portinfo test.""" diff --git a/neutron/tests/unit/nec/test_pfc_driver.py b/neutron/tests/unit/nec/test_pfc_driver.py index 0d7d36f9726..f5b27036d5c 100644 --- a/neutron/tests/unit/nec/test_pfc_driver.py +++ b/neutron/tests/unit/nec/test_pfc_driver.py @@ -56,7 +56,6 @@ class PFCDriverTestBase(base.BaseTestCase): self.driver = drivers.get_driver(self.driver)(TestConfig) self.do_request = mock.patch.object(ofc.OFCClient, 'do_request').start() - self.addCleanup(mock.patch.stopall) def get_ofc_item_random_params(self): """create random parameters for ofc_item test.""" diff --git a/neutron/tests/unit/nec/test_router.py b/neutron/tests/unit/nec/test_router.py index 8f608e75b47..5f3fc0035f5 100644 --- a/neutron/tests/unit/nec/test_router.py +++ b/neutron/tests/unit/nec/test_router.py @@ -26,7 +26,6 @@ class NecRouterL3AgentTestCase(test_ext_route.ExtraRouteDBIntTestCase): _plugin_name = test_nec_plugin.PLUGIN_NAME def setUp(self): - self.addCleanup(mock.patch.stopall) mock.patch(test_nec_plugin.OFC_MANAGER).start() super(NecRouterL3AgentTestCase, self).setUp(self._plugin_name) diff --git a/neutron/tests/unit/nec/test_security_group.py b/neutron/tests/unit/nec/test_security_group.py index 6d0a8f31af1..5b226459600 100644 --- a/neutron/tests/unit/nec/test_security_group.py +++ b/neutron/tests/unit/nec/test_security_group.py @@ -36,7 +36,6 @@ class NecSecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase): def setUp(self, plugin=None): test_sg_rpc.set_firewall_driver(test_sg_rpc.FIREWALL_HYBRID_DRIVER) - self.addCleanup(mock.patch.stopall) mock.patch(NOTIFIER).start() mock.patch(OFC_MANAGER).start() self._attribute_map_bk_ = {} diff --git a/neutron/tests/unit/nec/test_trema_driver.py b/neutron/tests/unit/nec/test_trema_driver.py index 16b838e4c4c..0eb219f985c 100644 --- a/neutron/tests/unit/nec/test_trema_driver.py +++ b/neutron/tests/unit/nec/test_trema_driver.py @@ -41,7 +41,6 @@ class TremaDriverTestBase(base.BaseTestCase): self.driver = drivers.get_driver(self.driver_name)(TestConfig) self.do_request = mock.patch.object(ofc_client.OFCClient, 'do_request').start() - self.addCleanup(mock.patch.stopall) def get_ofc_item_random_params(self): """create random parameters for ofc_item test.""" diff --git a/neutron/tests/unit/ofagent/test_ofa_neutron_agent.py b/neutron/tests/unit/ofagent/test_ofa_neutron_agent.py index 1c5b3471589..3c3d552d345 100644 --- a/neutron/tests/unit/ofagent/test_ofa_neutron_agent.py +++ b/neutron/tests/unit/ofagent/test_ofa_neutron_agent.py @@ -41,7 +41,6 @@ class OFAAgentTestCase(base.BaseTestCase): def setUp(self): super(OFAAgentTestCase, self).setUp() - self.addCleanup(mock.patch.stopall) self.fake_oflib_of = fake_oflib.patch_fake_oflib_of().start() self.mod_agent = importutils.import_module(self._AGENT_NAME) self.ryuapp = mock.Mock() diff --git a/neutron/tests/unit/oneconvergence/test_nvsd_agent.py b/neutron/tests/unit/oneconvergence/test_nvsd_agent.py index 05715a52d95..d36e4934e84 100644 --- a/neutron/tests/unit/oneconvergence/test_nvsd_agent.py +++ b/neutron/tests/unit/oneconvergence/test_nvsd_agent.py @@ -34,7 +34,6 @@ class TestOneConvergenceAgentBase(base.BaseTestCase): def setUp(self): super(TestOneConvergenceAgentBase, self).setUp() self.addCleanup(cfg.CONF.reset) - self.addCleanup(mock.patch.stopall) cfg.CONF.set_override('rpc_backend', 'neutron.openstack.common.rpc.impl_fake') with contextlib.nested( diff --git a/neutron/tests/unit/oneconvergence/test_nvsd_plugin.py b/neutron/tests/unit/oneconvergence/test_nvsd_plugin.py index fee4339c8f6..02b0fef1d72 100644 --- a/neutron/tests/unit/oneconvergence/test_nvsd_plugin.py +++ b/neutron/tests/unit/oneconvergence/test_nvsd_plugin.py @@ -43,8 +43,6 @@ class OneConvergencePluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase): self.nvsdlib = mock.Mock() self.nvsdlib.create_network.side_effect = side_effect - self.addCleanup(mock.patch.stopall) - with mock.patch.object(nvsd_plugin.OneConvergencePluginV2, 'oneconvergence_init', new=mocked_oneconvergence_init): @@ -121,7 +119,6 @@ class TestOneConvergenceL3NatTestCase(test_l3_plugin.L3NatDBIntTestCase): self.nvsdlib = mock.Mock() self.nvsdlib.create_network.side_effect = side_effect - self.addCleanup(mock.patch.stopall) ext_mgr = test_l3_plugin.L3TestExtensionManager() with mock.patch.object(nvsd_plugin.OneConvergencePluginV2, diff --git a/neutron/tests/unit/oneconvergence/test_security_group.py b/neutron/tests/unit/oneconvergence/test_security_group.py index e1951d17f52..db786ec21d1 100644 --- a/neutron/tests/unit/oneconvergence/test_security_group.py +++ b/neutron/tests/unit/oneconvergence/test_security_group.py @@ -43,9 +43,7 @@ class OneConvergenceSecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase): self.nvsdlib = mock.Mock() self.nvsdlib.create_network.side_effect = side_effect - self.addCleanup(mock.patch.stopall) test_sg_rpc.set_firewall_driver(test_sg_rpc.FIREWALL_HYBRID_DRIVER) - self.addCleanup(mock.patch.stopall) notifier_cls = mock.patch(AGENTNOTIFIER).start() self.notifier = mock.Mock() notifier_cls.return_value = self.notifier diff --git a/neutron/tests/unit/openvswitch/test_ovs_lib.py b/neutron/tests/unit/openvswitch/test_ovs_lib.py index c3334279aa1..d8b48651840 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_lib.py +++ b/neutron/tests/unit/openvswitch/test_ovs_lib.py @@ -111,7 +111,6 @@ class OVS_Lib_Test(base.BaseTestCase): self.br = ovs_lib.OVSBridge(self.BR_NAME, self.root_helper) self.execute = mock.patch.object( utils, "execute", spec=utils.execute).start() - self.addCleanup(mock.patch.stopall) def test_vifport(self): """Create and stringify vif port, confirm no exceptions.""" diff --git a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py index 0e998f9fb3c..4849eddf34f 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py @@ -90,7 +90,6 @@ class TestOvsNeutronAgent(base.BaseTestCase): def setUp(self): super(TestOvsNeutronAgent, self).setUp() self.addCleanup(cfg.CONF.reset) - self.addCleanup(mock.patch.stopall) notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() self.notifier = mock.Mock() @@ -765,7 +764,6 @@ class AncillaryBridgesTest(base.BaseTestCase): def setUp(self): super(AncillaryBridgesTest, self).setUp() self.addCleanup(cfg.CONF.reset) - self.addCleanup(mock.patch.stopall) notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() self.notifier = mock.Mock() diff --git a/neutron/tests/unit/openvswitch/test_ovs_security_group.py b/neutron/tests/unit/openvswitch/test_ovs_security_group.py index eb9ea0b15a6..c681af82713 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_security_group.py +++ b/neutron/tests/unit/openvswitch/test_ovs_security_group.py @@ -34,7 +34,6 @@ class OpenvswitchSecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase): def setUp(self, plugin=None): test_sg_rpc.set_firewall_driver(test_sg_rpc.FIREWALL_HYBRID_DRIVER) - self.addCleanup(mock.patch.stopall) notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() self.notifier = mock.Mock() diff --git a/neutron/tests/unit/openvswitch/test_ovs_tunnel.py b/neutron/tests/unit/openvswitch/test_ovs_tunnel.py index f6abc5c65e0..8de601a047a 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_tunnel.py +++ b/neutron/tests/unit/openvswitch/test_ovs_tunnel.py @@ -69,7 +69,6 @@ class TunnelTest(base.BaseTestCase): cfg.CONF.set_override('rpc_backend', 'neutron.openstack.common.rpc.impl_fake') cfg.CONF.set_override('report_interval', 0, 'AGENT') - self.addCleanup(mock.patch.stopall) self.INT_BRIDGE = 'integration_bridge' self.TUN_BRIDGE = 'tunnel_bridge' diff --git a/neutron/tests/unit/ryu/test_ryu_agent.py b/neutron/tests/unit/ryu/test_ryu_agent.py index 9bab0361226..dee2c2e790d 100644 --- a/neutron/tests/unit/ryu/test_ryu_agent.py +++ b/neutron/tests/unit/ryu/test_ryu_agent.py @@ -29,7 +29,6 @@ class RyuAgentTestCase(base.BaseTestCase): def setUp(self): super(RyuAgentTestCase, self).setUp() - self.addCleanup(mock.patch.stopall) self.fake_ryu = fake_ryu.patch_fake_ryu_client().start() self.mod_agent = importutils.import_module(self._AGENT_NAME) diff --git a/neutron/tests/unit/ryu/test_ryu_security_group.py b/neutron/tests/unit/ryu/test_ryu_security_group.py index 48e8d50bae9..16f92f088fe 100644 --- a/neutron/tests/unit/ryu/test_ryu_security_group.py +++ b/neutron/tests/unit/ryu/test_ryu_security_group.py @@ -37,7 +37,6 @@ class RyuSecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase): def setUp(self, plugin=None): test_sg_rpc.set_firewall_driver(test_sg_rpc.FIREWALL_HYBRID_DRIVER) - self.addCleanup(mock.patch.stopall) self.fake_ryu = fake_ryu.patch_fake_ryu_client().start() notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() diff --git a/neutron/tests/unit/services/firewall/agents/l3reference/test_firewall_l3_agent.py b/neutron/tests/unit/services/firewall/agents/l3reference/test_firewall_l3_agent.py index 9d7f4079b89..dc0502abb31 100644 --- a/neutron/tests/unit/services/firewall/agents/l3reference/test_firewall_l3_agent.py +++ b/neutron/tests/unit/services/firewall/agents/l3reference/test_firewall_l3_agent.py @@ -48,7 +48,6 @@ class FWaasAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, FWaasHelper): class TestFwaasL3AgentRpcCallback(base.BaseTestCase): def setUp(self): super(TestFwaasL3AgentRpcCallback, self).setUp() - self.addCleanup(mock.patch.stopall) self.conf = cfg.ConfigOpts() self.conf.register_opts(base_config.core_opts) diff --git a/neutron/tests/unit/services/firewall/agents/test_firewall_agent_api.py b/neutron/tests/unit/services/firewall/agents/test_firewall_agent_api.py index de3a60a82ee..3b76c5af379 100644 --- a/neutron/tests/unit/services/firewall/agents/test_firewall_agent_api.py +++ b/neutron/tests/unit/services/firewall/agents/test_firewall_agent_api.py @@ -50,7 +50,6 @@ class NoopFwaasDriver(base_driver.FwaasDriverBase): class TestFWaaSAgentApi(base.BaseTestCase): def setUp(self): super(TestFWaaSAgentApi, self).setUp() - self.addCleanup(mock.patch.stopall) self.api = api.FWaaSPluginApiMixin( 'topic', diff --git a/neutron/tests/unit/services/firewall/agents/varmour/test_varmour_router.py b/neutron/tests/unit/services/firewall/agents/varmour/test_varmour_router.py index 3a7ddd8b941..6a08e34b292 100644 --- a/neutron/tests/unit/services/firewall/agents/varmour/test_varmour_router.py +++ b/neutron/tests/unit/services/firewall/agents/varmour/test_varmour_router.py @@ -80,8 +80,6 @@ class TestVarmourRouter(base.BaseTestCase): 'neutron.openstack.common.loopingcall.FixedIntervalLoopingCall') self.looping_call_p.start() - self.addCleanup(mock.patch.stopall) - def _create_router(self): router = varmour_router.vArmourL3NATAgent(HOSTNAME, self.conf) router.rest.server = FAKE_DIRECTOR diff --git a/neutron/tests/unit/services/firewall/drivers/varmour/test_varmour_fwaas.py b/neutron/tests/unit/services/firewall/drivers/varmour/test_varmour_fwaas.py index 7c6bd667370..c65af6bc583 100644 --- a/neutron/tests/unit/services/firewall/drivers/varmour/test_varmour_fwaas.py +++ b/neutron/tests/unit/services/firewall/drivers/varmour/test_varmour_fwaas.py @@ -81,8 +81,6 @@ class TestBasicRouterOperations(base.BaseTestCase): 'neutron.openstack.common.loopingcall.FixedIntervalLoopingCall') self.looping_call_p.start() - self.addCleanup(mock.patch.stopall) - def _create_router(self): router = varmour_router.vArmourL3NATAgent(HOSTNAME, self.conf) router.rest.server = FAKE_DIRECTOR diff --git a/neutron/tests/unit/services/firewall/test_fwaas_plugin.py b/neutron/tests/unit/services/firewall/test_fwaas_plugin.py index 4d02639f651..7591f2805c0 100644 --- a/neutron/tests/unit/services/firewall/test_fwaas_plugin.py +++ b/neutron/tests/unit/services/firewall/test_fwaas_plugin.py @@ -154,7 +154,6 @@ class TestFirewallCallbacks(test_db_firewall.FirewallPluginDbTestCase): class TestFirewallAgentApi(base.BaseTestCase): def setUp(self): super(TestFirewallAgentApi, self).setUp() - self.addCleanup(mock.patch.stopall) self.api = fwaas_plugin.FirewallAgentApi('topic', 'host') self.mock_fanoutcast = mock.patch.object(self.api, diff --git a/neutron/tests/unit/services/loadbalancer/agent/test_agent_manager.py b/neutron/tests/unit/services/loadbalancer/agent/test_agent_manager.py index fdff11b4d7b..c17e56ab948 100644 --- a/neutron/tests/unit/services/loadbalancer/agent/test_agent_manager.py +++ b/neutron/tests/unit/services/loadbalancer/agent/test_agent_manager.py @@ -28,7 +28,6 @@ from neutron.tests import base class TestManager(base.BaseTestCase): def setUp(self): super(TestManager, self).setUp() - self.addCleanup(mock.patch.stopall) mock_conf = mock.Mock() mock_conf.device_driver = ['devdriver'] diff --git a/neutron/tests/unit/services/loadbalancer/agent/test_api.py b/neutron/tests/unit/services/loadbalancer/agent/test_api.py index dcd6025bd3f..94513ee9d1c 100644 --- a/neutron/tests/unit/services/loadbalancer/agent/test_api.py +++ b/neutron/tests/unit/services/loadbalancer/agent/test_api.py @@ -25,7 +25,6 @@ from neutron.tests import base class TestApiCache(base.BaseTestCase): def setUp(self): super(TestApiCache, self).setUp() - self.addCleanup(mock.patch.stopall) self.api = api.LbaasAgentApi('topic', mock.sentinel.context, 'host') self.make_msg = mock.patch.object(self.api, 'make_msg').start() diff --git a/neutron/tests/unit/services/loadbalancer/drivers/haproxy/test_namespace_driver.py b/neutron/tests/unit/services/loadbalancer/drivers/haproxy/test_namespace_driver.py index 49fba192440..b98cc29f208 100644 --- a/neutron/tests/unit/services/loadbalancer/drivers/haproxy/test_namespace_driver.py +++ b/neutron/tests/unit/services/loadbalancer/drivers/haproxy/test_namespace_driver.py @@ -30,7 +30,6 @@ from neutron.tests import base class TestHaproxyNSDriver(base.BaseTestCase): def setUp(self): super(TestHaproxyNSDriver, self).setUp() - self.addCleanup(mock.patch.stopall) conf = mock.Mock() conf.haproxy.loadbalancer_state_path = '/the/path' diff --git a/neutron/tests/unit/services/loadbalancer/drivers/netscaler/test_ncc_client.py b/neutron/tests/unit/services/loadbalancer/drivers/netscaler/test_ncc_client.py index d5eb6a7152a..5e731304de0 100644 --- a/neutron/tests/unit/services/loadbalancer/drivers/netscaler/test_ncc_client.py +++ b/neutron/tests/unit/services/loadbalancer/drivers/netscaler/test_ncc_client.py @@ -46,7 +46,6 @@ class TestNSClient(testlib_api.WebTestCase): self.request_method_mock = mock.Mock() requests.request = self.request_method_mock self.testclient = self._get_nsclient() - self.addCleanup(mock.patch.stopall) def test_instantiate_nsclient_with_empty_uri(self): """Asserts that a call with empty URI will raise an exception.""" diff --git a/neutron/tests/unit/services/loadbalancer/drivers/netscaler/test_netscaler_driver.py b/neutron/tests/unit/services/loadbalancer/drivers/netscaler/test_netscaler_driver.py index c8962e1e493..e10c1a3d766 100644 --- a/neutron/tests/unit/services/loadbalancer/drivers/netscaler/test_netscaler_driver.py +++ b/neutron/tests/unit/services/loadbalancer/drivers/netscaler/test_netscaler_driver.py @@ -91,7 +91,6 @@ class TestNetScalerPluginDriver(TestLoadBalancerPluginBase): netscaler_driver.NetScalerPluginDriver(self.plugin_instance)) self.driver = self.plugin_instance.drivers[LBAAS_PROVIDER_NAME] self.context = context.get_admin_context() - self.addCleanup(mock.patch.stopall) def test_create_vip(self): with contextlib.nested( diff --git a/neutron/tests/unit/services/loadbalancer/drivers/radware/test_plugin_driver.py b/neutron/tests/unit/services/loadbalancer/drivers/radware/test_plugin_driver.py index 1c0bf1f71a0..b5344bfd32c 100644 --- a/neutron/tests/unit/services/loadbalancer/drivers/radware/test_plugin_driver.py +++ b/neutron/tests/unit/services/loadbalancer/drivers/radware/test_plugin_driver.py @@ -116,7 +116,6 @@ class TestLoadBalancerPlugin(TestLoadBalancerPluginBase): radware_driver.rest_client.call = self.rest_call_mock self.addCleanup(radware_driver.completion_handler.join) - self.addCleanup(mock.patch.stopall) def test_verify_workflow_templates(self): """Test the rest call failure handling by Exception raising.""" diff --git a/neutron/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py b/neutron/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py index de9e8fbd654..15b8e6d4a40 100644 --- a/neutron/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py +++ b/neutron/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py @@ -46,7 +46,6 @@ class TestLoadBalancerPluginBase( self.mock_importer = mock.patch.object( agent_driver_base, 'importutils').start() - self.addCleanup(mock.patch.stopall) # needed to reload provider configuration st_db.ServiceTypeManager._instance = None @@ -74,8 +73,6 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase): '.LbaasAgentSchedulerDbMixin.get_lbaas_agents') get_lbaas_agents_patcher.start() - self.addCleanup(mock.patch.stopall) - def test_get_ready_devices(self): with self.vip() as vip: with mock.patch('neutron.services.loadbalancer.agent_scheduler' @@ -429,7 +426,6 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase): class TestLoadBalancerAgentApi(base.BaseTestCase): def setUp(self): super(TestLoadBalancerAgentApi, self).setUp() - self.addCleanup(mock.patch.stopall) self.api = agent_driver_base.LoadBalancerAgentApi('topic') self.mock_cast = mock.patch.object(self.api, 'cast').start() @@ -521,8 +517,6 @@ class TestLoadBalancerPluginNotificationWrapper(TestLoadBalancerPluginBase): self.plugin_instance )) - self.addCleanup(mock.patch.stopall) - def test_create_vip(self): with self.subnet() as subnet: with self.pool(subnet=subnet) as pool: diff --git a/neutron/tests/unit/services/metering/test_metering_agent.py b/neutron/tests/unit/services/metering/test_metering_agent.py index 433e2e20890..0c3a410ea64 100644 --- a/neutron/tests/unit/services/metering/test_metering_agent.py +++ b/neutron/tests/unit/services/metering/test_metering_agent.py @@ -70,8 +70,6 @@ class TestMeteringOperations(base.BaseTestCase): self.agent = metering_agent.MeteringAgent('my agent', cfg.CONF) self.driver = self.agent.metering_driver - self.addCleanup(mock.patch.stopall) - def tearDown(self): test_notifier.NOTIFICATIONS = [] super(TestMeteringOperations, self).tearDown() @@ -148,8 +146,6 @@ class TestMeteringDriver(base.BaseTestCase): self.driver = mock.Mock() self.agent.metering_driver = self.driver - self.addCleanup(mock.patch.stopall) - def test_add_metering_label_with_bad_driver_impl(self): del self.driver.add_metering_label diff --git a/neutron/tests/unit/services/metering/test_metering_plugin.py b/neutron/tests/unit/services/metering/test_metering_plugin.py index e46c77d9cb5..301b5509450 100644 --- a/neutron/tests/unit/services/metering/test_metering_plugin.py +++ b/neutron/tests/unit/services/metering/test_metering_plugin.py @@ -71,8 +71,6 @@ class TestMeteringPlugin(test_db_plugin.NeutronDbPluginV2TestCase, super(TestMeteringPlugin, self).setUp(plugin=plugin, ext_mgr=ext_mgr, service_plugins=service_plugins) - self.addCleanup(mock.patch.stopall) - self.uuid = '654f6b9d-0f36-4ae5-bd1b-01616794ca60' uuid = 'neutron.openstack.common.uuidutils.generate_uuid' @@ -279,8 +277,6 @@ class TestMeteringPluginL3AgentScheduler( self.uuid = '654f6b9d-0f36-4ae5-bd1b-01616794ca60' - self.addCleanup(mock.patch.stopall) - uuid = 'neutron.openstack.common.uuidutils.generate_uuid' self.uuid_patch = mock.patch(uuid, return_value=self.uuid) self.mock_uuid = self.uuid_patch.start() diff --git a/neutron/tests/unit/services/vpn/device_drivers/test_cisco_ipsec.py b/neutron/tests/unit/services/vpn/device_drivers/test_cisco_ipsec.py index 924ff447e65..d2ff8796e95 100644 --- a/neutron/tests/unit/services/vpn/device_drivers/test_cisco_ipsec.py +++ b/neutron/tests/unit/services/vpn/device_drivers/test_cisco_ipsec.py @@ -50,7 +50,6 @@ FIND_CFG_FOR_CSRS = ('neutron.services.vpn.device_drivers.cisco_ipsec.' class TestCiscoCsrIPSecConnection(base.BaseTestCase): def setUp(self): super(TestCiscoCsrIPSecConnection, self).setUp() - self.addCleanup(mock.patch.stopall) self.conn_info = { u'id': '123', u'status': constants.PENDING_CREATE, @@ -194,7 +193,6 @@ class TestCiscoCsrIPsecConnectionCreateTransforms(base.BaseTestCase): def setUp(self): super(TestCiscoCsrIPsecConnectionCreateTransforms, self).setUp() - self.addCleanup(mock.patch.stopall) self.conn_info = { u'id': '123', u'status': constants.PENDING_CREATE, @@ -360,7 +358,6 @@ class TestCiscoCsrIPsecDeviceDriverSyncStatuses(base.BaseTestCase): def setUp(self): super(TestCiscoCsrIPsecDeviceDriverSyncStatuses, self).setUp() - self.addCleanup(mock.patch.stopall) for klass in ['neutron.openstack.common.rpc.create_connection', 'neutron.context.get_admin_context_without_session', 'neutron.openstack.common.' @@ -1211,10 +1208,6 @@ class TestCiscoCsrIPsecDeviceDriverSyncStatuses(base.BaseTestCase): class TestCiscoCsrIPsecDeviceDriverConfigLoading(base.BaseTestCase): - def setUp(self): - super(TestCiscoCsrIPsecDeviceDriverConfigLoading, self).setUp() - self.addCleanup(mock.patch.stopall) - def create_tempfile(self, contents): (fd, path) = tempfile.mkstemp(prefix='test', suffix='.conf') try: diff --git a/neutron/tests/unit/services/vpn/device_drivers/test_ipsec.py b/neutron/tests/unit/services/vpn/device_drivers/test_ipsec.py index d149e502456..bbd65928abb 100644 --- a/neutron/tests/unit/services/vpn/device_drivers/test_ipsec.py +++ b/neutron/tests/unit/services/vpn/device_drivers/test_ipsec.py @@ -42,7 +42,6 @@ FAKE_VPN_SERVICE = { class TestIPsecDeviceDriver(base.BaseTestCase): def setUp(self, driver=ipsec_driver.OpenSwanDriver): super(TestIPsecDeviceDriver, self).setUp() - self.addCleanup(mock.patch.stopall) for klass in [ 'os.makedirs', diff --git a/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py b/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py index de0dfb7b7f3..7c53e6fa7a6 100644 --- a/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py +++ b/neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py @@ -44,7 +44,6 @@ class TestCiscoIPsecDriverValidation(base.BaseTestCase): def setUp(self): super(TestCiscoIPsecDriverValidation, self).setUp() - self.addCleanup(mock.patch.stopall) mock.patch('neutron.openstack.common.rpc.create_connection').start() self.service_plugin = mock.Mock() self.driver = ipsec_driver.CiscoCsrIPsecVPNDriver(self.service_plugin) @@ -181,7 +180,6 @@ class TestCiscoIPsecDriverMapping(base.BaseTestCase): def setUp(self): super(TestCiscoIPsecDriverMapping, self).setUp() - self.addCleanup(mock.patch.stopall) self.context = mock.patch.object(n_ctx, 'Context').start() self.session = self.context.session self.query_mock = self.session.query.return_value.order_by @@ -284,7 +282,6 @@ class TestCiscoIPsecDriver(base.BaseTestCase): def setUp(self): super(TestCiscoIPsecDriver, self).setUp() - self.addCleanup(mock.patch.stopall) dbapi.configure_db() self.addCleanup(dbapi.clear_db) mock.patch('neutron.openstack.common.rpc.create_connection').start() diff --git a/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py b/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py index 627724d54b8..33aebe97769 100644 --- a/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py +++ b/neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py @@ -37,7 +37,6 @@ FAKE_HOST = 'fake_host' class TestIPsecDriver(base.BaseTestCase): def setUp(self): super(TestIPsecDriver, self).setUp() - self.addCleanup(mock.patch.stopall) mock.patch('neutron.openstack.common.rpc.create_connection').start() l3_agent = mock.Mock() diff --git a/neutron/tests/unit/services/vpn/test_vpn_agent.py b/neutron/tests/unit/services/vpn/test_vpn_agent.py index 4e60435178f..09d7260625c 100644 --- a/neutron/tests/unit/services/vpn/test_vpn_agent.py +++ b/neutron/tests/unit/services/vpn/test_vpn_agent.py @@ -47,7 +47,6 @@ class NoopDeviceDriver(device_drivers.DeviceDriver): class TestVPNAgent(base.BaseTestCase): def setUp(self): super(TestVPNAgent, self).setUp() - self.addCleanup(mock.patch.stopall) self.conf = cfg.CONF self.conf.register_opts(base_config.core_opts) self.conf.register_opts(l3_agent.L3NATAgent.OPTS) diff --git a/neutron/tests/unit/services/vpn/test_vpnaas_driver_plugin.py b/neutron/tests/unit/services/vpn/test_vpnaas_driver_plugin.py index 8c25d7e4ccf..f5ed5bc01b5 100644 --- a/neutron/tests/unit/services/vpn/test_vpnaas_driver_plugin.py +++ b/neutron/tests/unit/services/vpn/test_vpnaas_driver_plugin.py @@ -35,7 +35,6 @@ class TestVPNDriverPlugin(test_db_vpnaas.TestVpnaas, test_agent_scheduler.AgentSchedulerTestMixIn, test_agent_ext_plugin.AgentDBTestMixIn): def setUp(self): - self.addCleanup(mock.patch.stopall) self.adminContext = context.get_admin_context() driver_cls_p = mock.patch( 'neutron.services.vpn.' diff --git a/neutron/tests/unit/test_api_v2_extension.py b/neutron/tests/unit/test_api_v2_extension.py index 0266d37efc2..812b797cae7 100644 --- a/neutron/tests/unit/test_api_v2_extension.py +++ b/neutron/tests/unit/test_api_v2_extension.py @@ -46,7 +46,6 @@ class ExtensionTestCase(testlib_api.WebTestCase): supported_extension_aliases=None, use_quota=False, ): - self.addCleanup(mock.patch.stopall) self._resource_prefix = resource_prefix self._plural_mappings = plural_mappings or {} diff --git a/neutron/tests/unit/test_debug_commands.py b/neutron/tests/unit/test_debug_commands.py index 15b62f0e66f..7827a095bd2 100644 --- a/neutron/tests/unit/test_debug_commands.py +++ b/neutron/tests/unit/test_debug_commands.py @@ -45,7 +45,6 @@ class TestDebugCommands(base.BaseTestCase): config.register_root_helper(cfg.CONF) cfg.CONF.set_override('use_namespaces', True) - self.addCleanup(mock.patch.stopall) device_exists_p = mock.patch( 'neutron.agent.linux.ip_lib.device_exists', return_value=False) device_exists_p.start() diff --git a/neutron/tests/unit/test_dhcp_agent.py b/neutron/tests/unit/test_dhcp_agent.py index e544118fee2..711c287d198 100644 --- a/neutron/tests/unit/test_dhcp_agent.py +++ b/neutron/tests/unit/test_dhcp_agent.py @@ -140,7 +140,6 @@ class TestDhcpAgent(base.BaseTestCase): self.driver_cls.return_value = self.driver self.mock_makedirs_p = mock.patch("os.makedirs") self.mock_makedirs = self.mock_makedirs_p.start() - self.addCleanup(mock.patch.stopall) def test_dhcp_agent_manager(self): state_rpc_str = 'neutron.agent.rpc.PluginReportStateAPI' diff --git a/neutron/tests/unit/test_iptables_manager.py b/neutron/tests/unit/test_iptables_manager.py index 7da1b08c520..47c376ece8e 100644 --- a/neutron/tests/unit/test_iptables_manager.py +++ b/neutron/tests/unit/test_iptables_manager.py @@ -72,7 +72,6 @@ class IptablesManagerStateFulTestCase(base.BaseTestCase): self.iptables = (iptables_manager. IptablesManager(root_helper=self.root_helper)) self.execute = mock.patch.object(self.iptables, "execute").start() - self.addCleanup(mock.patch.stopall) def test_binary_name(self): self.assertEqual(iptables_manager.binary_name, diff --git a/neutron/tests/unit/test_l3_agent.py b/neutron/tests/unit/test_l3_agent.py index ac6662b845b..201e9d74c04 100644 --- a/neutron/tests/unit/test_l3_agent.py +++ b/neutron/tests/unit/test_l3_agent.py @@ -90,8 +90,6 @@ class TestBasicRouterOperations(base.BaseTestCase): 'neutron.openstack.common.loopingcall.FixedIntervalLoopingCall') self.looping_call_p.start() - self.addCleanup(mock.patch.stopall) - def test_router_info_create(self): id = _uuid() ri = l3_agent.RouterInfo(id, self.conf.root_helper, @@ -1136,7 +1134,6 @@ class TestL3AgentEventHandler(base.BaseTestCase): 'neutron.openstack.common.loopingcall.FixedIntervalLoopingCall') looping_call_p.start() self.agent = l3_agent.L3NATAgent(HOSTNAME) - self.addCleanup(mock.patch.stopall) def test_spawn_metadata_proxy(self): router_id = _uuid() diff --git a/neutron/tests/unit/test_linux_dhcp.py b/neutron/tests/unit/test_linux_dhcp.py index 9a6c7e19f65..72d633ce95d 100644 --- a/neutron/tests/unit/test_linux_dhcp.py +++ b/neutron/tests/unit/test_linux_dhcp.py @@ -408,7 +408,6 @@ class TestBase(base.BaseTestCase): self.execute_p = mock.patch('neutron.agent.linux.utils.execute') self.safe = self.replace_p.start() self.execute = self.execute_p.start() - self.addCleanup(mock.patch.stopall) class TestDhcpBase(TestBase): diff --git a/neutron/tests/unit/test_linux_interface.py b/neutron/tests/unit/test_linux_interface.py index 7c84623fc00..81a6cc0aef0 100644 --- a/neutron/tests/unit/test_linux_interface.py +++ b/neutron/tests/unit/test_linux_interface.py @@ -521,7 +521,6 @@ class TestMidonetInterfaceDriver(TestBase): config.register_root_helper(self.conf) self.device_exists_p = mock.patch.object(ip_lib, 'device_exists') self.device_exists = self.device_exists_p.start() - self.addCleanup(mock.patch.stopall) self.driver = interface.MidonetInterfaceDriver(self.conf) self.network_id = uuidutils.generate_uuid() self.port_id = uuidutils.generate_uuid() diff --git a/neutron/tests/unit/test_metadata_agent.py b/neutron/tests/unit/test_metadata_agent.py index 9cba5ddda68..a87cdfd3f9d 100644 --- a/neutron/tests/unit/test_metadata_agent.py +++ b/neutron/tests/unit/test_metadata_agent.py @@ -337,7 +337,6 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase): looping_call_p = mock.patch( 'neutron.openstack.common.loopingcall.FixedIntervalLoopingCall') self.looping_mock = looping_call_p.start() - self.addCleanup(mock.patch.stopall) self.cfg.CONF.metadata_proxy_socket = '/the/path' self.cfg.CONF.metadata_workers = 0 self.cfg.CONF.metadata_backlog = 128 diff --git a/neutron/tests/unit/test_security_groups_rpc.py b/neutron/tests/unit/test_security_groups_rpc.py index eeb7602f85c..63cbb4a7552 100644 --- a/neutron/tests/unit/test_security_groups_rpc.py +++ b/neutron/tests/unit/test_security_groups_rpc.py @@ -506,7 +506,6 @@ class SecurityGroupAgentRpcTestCase(base.BaseTestCase): super(SecurityGroupAgentRpcTestCase, self).setUp() self.agent = sg_rpc.SecurityGroupAgentRpcMixin() self.agent.context = None - self.addCleanup(mock.patch.stopall) mock.patch('neutron.agent.linux.iptables_manager').start() self.agent.root_helper = 'sudo' self.agent.init_firewall(defer_refresh_firewall=defer_refresh_firewall) @@ -1437,7 +1436,6 @@ class TestSecurityGroupAgentWithIptables(base.BaseTestCase): 'firewall_driver', self.FIREWALL_DRIVER, group='SECURITYGROUP') - self.addCleanup(mock.patch.stopall) self.agent = sg_rpc.SecurityGroupAgentRpcMixin() self.agent.context = None diff --git a/neutron/tests/unit/vmware/extensions/test_networkgw.py b/neutron/tests/unit/vmware/extensions/test_networkgw.py index a0b26101b5c..54e328e9c97 100644 --- a/neutron/tests/unit/vmware/extensions/test_networkgw.py +++ b/neutron/tests/unit/vmware/extensions/test_networkgw.py @@ -868,7 +868,6 @@ class TestNetworkGateway(NsxPluginV2TestCase, delete_gw_dev_patcher.start() self.mock_get_gw_dev_status = get_gw_dev_status_patcher.start() - self.addCleanup(mock.patch.stopall) super(TestNetworkGateway, self).setUp(plugin=plugin, ext_mgr=ext_mgr) diff --git a/neutron/tests/unit/vmware/test_nsx_plugin.py b/neutron/tests/unit/vmware/test_nsx_plugin.py index abcb99a7f74..1baa44dd254 100644 --- a/neutron/tests/unit/vmware/test_nsx_plugin.py +++ b/neutron/tests/unit/vmware/test_nsx_plugin.py @@ -114,7 +114,6 @@ class NsxPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase): self.port_create_status = constants.PORT_STATUS_DOWN cfg.CONF.set_override('metadata_mode', None, 'NSX') self.addCleanup(self.fc.reset_all) - self.addCleanup(mock.patch.stopall) class TestBasicGet(test_plugin.TestBasicGet, NsxPluginV2TestCase): diff --git a/neutron/tests/unit/vmware/test_nsx_utils.py b/neutron/tests/unit/vmware/test_nsx_utils.py index a35b32796e1..d5c66cfc35a 100644 --- a/neutron/tests/unit/vmware/test_nsx_utils.py +++ b/neutron/tests/unit/vmware/test_nsx_utils.py @@ -29,10 +29,6 @@ from neutron.tests.unit.vmware.nsxlib import base as nsx_base class NsxUtilsTestCase(base.BaseTestCase): - def setUp(self): - self.addCleanup(mock.patch.stopall) - super(NsxUtilsTestCase, self).setUp() - def _mock_port_mapping_db_calls(self, ret_value): # Mock relevant db calls # This will allow for avoiding setting up the plugin @@ -276,7 +272,6 @@ class NsxUtilsTestCase(base.BaseTestCase): return_value=ret_value).start() mock.patch(nsx_method('add_neutron_nsx_security_group_mapping', module_name='dbexts.db')).start() - self.addCleanup(mock.patch.stopall) def _verify_get_nsx_sec_profile_id(self, exp_sec_prof_uuid): # The nsxlib and db calls are mocked, therefore the cluster diff --git a/neutron/tests/unit/vmware/vshield/test_edge_router.py b/neutron/tests/unit/vmware/vshield/test_edge_router.py index c0c01446e4e..918b8e03a0a 100644 --- a/neutron/tests/unit/vmware/vshield/test_edge_router.py +++ b/neutron/tests/unit/vmware/vshield/test_edge_router.py @@ -115,7 +115,6 @@ class ServiceRouterTest(test_nsx_plugin.L3NatTest, self.fc2.set_fake_nsx_api(self.fc) self.addCleanup(self.fc2.reset_all) - self.addCleanup(mock.patch.stopall) def tearDown(self): plugin = NeutronManager.get_plugin()