diff --git a/neutron/tests/unit/bigswitch/test_base.py b/neutron/tests/unit/bigswitch/test_base.py index a8eec715d..867b7eefb 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 385683ffe..5a5ee438e 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 21659694f..23f4f41c2 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 6a959d609..3379cb842 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 691b96156..bda949f51 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 1ac5b3163..1411cfa3c 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 9406a120b..62662036a 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 e90333634..e35cd9b0d 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 675daed7a..dfa74c07f 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 352405ad0..2698b3db3 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 34d71a71e..b0a06fa82 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 a78cc42e4..ace306c93 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 961340419..347de62c8 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 879398616..60c1770a5 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 341eaf774..2e4530615 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 78a0a7911..9aa470a30 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 a163e7382..e4543c21f 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 0d7d36f97..f5b27036d 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 8f608e75b..5f3fc0035 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 6d0a8f31a..5b2264596 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 16b838e4c..0eb219f98 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 1c5b34715..3c3d552d3 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 05715a52d..d36e4934e 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 fee4339c8..02b0fef1d 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 e1951d17f..db786ec21 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 c3334279a..d8b486518 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 0e998f9fb..4849eddf3 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 eb9ea0b15..c681af827 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 f6abc5c65..8de601a04 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 9bab03612..dee2c2e79 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 48e8d50ba..16f92f088 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 9d7f4079b..dc0502abb 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 de3a60a82..3b76c5af3 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 3a7ddd8b9..6a08e34b2 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 7c6bd6673..c65af6bc5 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 4d02639f6..7591f2805 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 fdff11b4d..c17e56ab9 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 dcd6025bd..94513ee9d 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 49fba1924..b98cc29f2 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 d5eb6a715..5e731304d 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 c8962e1e4..e10c1a3d7 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 1c0bf1f71..b5344bfd3 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 de9e8fbd6..15b8e6d4a 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 433e2e208..0c3a410ea 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 e46c77d9c..301b55094 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 924ff447e..d2ff8796e 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 d149e5024..bbd65928a 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 de0dfb7b7..7c53e6fa7 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 627724d54..33aebe977 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 4e6043517..09d726062 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 8c25d7e4c..f5ed5bc01 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 0266d37ef..812b797ca 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 15b62f0e6..7827a095b 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 e544118fe..711c287d1 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 7da1b08c5..47c376ece 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 ac6662b84..201e9d74c 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 9a6c7e19f..72d633ce9 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 7c84623fc..81a6cc0ae 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 9cba5ddda..a87cdfd3f 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 eeb7602f8..63cbb4a75 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 a0b26101b..54e328e9c 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 abcb99a7f..1baa44dd2 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 a35b32796..d5c66cfc3 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 c0c01446e..918b8e03a 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()