]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Removes calls to mock.patch.stopall in unit tests
authorKevin Benton <blak111@gmail.com>
Wed, 12 Mar 2014 02:13:30 +0000 (02:13 +0000)
committerKevin Benton <blak111@gmail.com>
Wed, 12 Mar 2014 04:17:11 +0000 (04:17 +0000)
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

64 files changed:
neutron/tests/unit/bigswitch/test_base.py
neutron/tests/unit/bigswitch/test_restproxy_agent.py
neutron/tests/unit/cisco/test_network_plugin.py
neutron/tests/unit/cisco/test_nexus_plugin.py
neutron/tests/unit/db/loadbalancer/test_db_loadbalancer.py
neutron/tests/unit/hyperv/test_hyperv_security_groups_driver.py
neutron/tests/unit/linuxbridge/test_lb_security_group.py
neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_mech.py
neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_nexus.py
neutron/tests/unit/ml2/drivers/test_l2population.py
neutron/tests/unit/ml2/test_security_group.py
neutron/tests/unit/mlnx/test_mlnx_neutron_agent.py
neutron/tests/unit/mlnx/test_mlnx_security_group.py
neutron/tests/unit/nec/test_agent_scheduler.py
neutron/tests/unit/nec/test_nec_agent.py
neutron/tests/unit/nec/test_nec_plugin.py
neutron/tests/unit/nec/test_ofc_manager.py
neutron/tests/unit/nec/test_pfc_driver.py
neutron/tests/unit/nec/test_router.py
neutron/tests/unit/nec/test_security_group.py
neutron/tests/unit/nec/test_trema_driver.py
neutron/tests/unit/ofagent/test_ofa_neutron_agent.py
neutron/tests/unit/oneconvergence/test_nvsd_agent.py
neutron/tests/unit/oneconvergence/test_nvsd_plugin.py
neutron/tests/unit/oneconvergence/test_security_group.py
neutron/tests/unit/openvswitch/test_ovs_lib.py
neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py
neutron/tests/unit/openvswitch/test_ovs_security_group.py
neutron/tests/unit/openvswitch/test_ovs_tunnel.py
neutron/tests/unit/ryu/test_ryu_agent.py
neutron/tests/unit/ryu/test_ryu_security_group.py
neutron/tests/unit/services/firewall/agents/l3reference/test_firewall_l3_agent.py
neutron/tests/unit/services/firewall/agents/test_firewall_agent_api.py
neutron/tests/unit/services/firewall/agents/varmour/test_varmour_router.py
neutron/tests/unit/services/firewall/drivers/varmour/test_varmour_fwaas.py
neutron/tests/unit/services/firewall/test_fwaas_plugin.py
neutron/tests/unit/services/loadbalancer/agent/test_agent_manager.py
neutron/tests/unit/services/loadbalancer/agent/test_api.py
neutron/tests/unit/services/loadbalancer/drivers/haproxy/test_namespace_driver.py
neutron/tests/unit/services/loadbalancer/drivers/netscaler/test_ncc_client.py
neutron/tests/unit/services/loadbalancer/drivers/netscaler/test_netscaler_driver.py
neutron/tests/unit/services/loadbalancer/drivers/radware/test_plugin_driver.py
neutron/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py
neutron/tests/unit/services/metering/test_metering_agent.py
neutron/tests/unit/services/metering/test_metering_plugin.py
neutron/tests/unit/services/vpn/device_drivers/test_cisco_ipsec.py
neutron/tests/unit/services/vpn/device_drivers/test_ipsec.py
neutron/tests/unit/services/vpn/service_drivers/test_cisco_ipsec.py
neutron/tests/unit/services/vpn/service_drivers/test_ipsec.py
neutron/tests/unit/services/vpn/test_vpn_agent.py
neutron/tests/unit/services/vpn/test_vpnaas_driver_plugin.py
neutron/tests/unit/test_api_v2_extension.py
neutron/tests/unit/test_debug_commands.py
neutron/tests/unit/test_dhcp_agent.py
neutron/tests/unit/test_iptables_manager.py
neutron/tests/unit/test_l3_agent.py
neutron/tests/unit/test_linux_dhcp.py
neutron/tests/unit/test_linux_interface.py
neutron/tests/unit/test_metadata_agent.py
neutron/tests/unit/test_security_groups_rpc.py
neutron/tests/unit/vmware/extensions/test_networkgw.py
neutron/tests/unit/vmware/test_nsx_plugin.py
neutron/tests/unit/vmware/test_nsx_utils.py
neutron/tests/unit/vmware/vshield/test_edge_router.py

index a8eec715d13e3ba8aee151ef3e70b52638312832..867b7eefb549e979e807dcc399d89af8a29227f3 100644 (file)
@@ -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()
index 385683ffe14fe87d0b1e2de350cd9b5b1830ff41..5a5ee438eb7281c6d1801c8700a5e8940b1dd068 100644 (file)
@@ -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)
 
 
index 21659694f70eae5e204584dcc9cbc37601c8e89f..23f4f41c262e388df36486f40f4c3927614101d4 100644 (file)
@@ -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(),
index 6a959d6095c5d33a835f2a40c60e3e099db3df7a..3379cb842484425971fca9293eb540405a8910cf 100644 (file)
@@ -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."""
index 691b9615697afd1e1b1c8f39747ab11e5bfedd24..bda949f51844da65d4fa80d9d05d10fa9e306e83 100644 (file)
@@ -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
index 1ac5b316321c580d3d27193a011166cb7d1fd5bb..1411cfa3c42999cbcbd277bb63d04cf0a7d87f8a 100644 (file)
@@ -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()
 
index 9406a120ba6503e159cb76f61f032a55dfca44a7..62662036a32561698b7b397ce9f4aa8b4f522114 100644 (file)
@@ -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_
index e90333634aad783b83ac1bc1296470e78f485015..e35cd9b0d2977ffe395cc66bce9513e9ba3e638b 100644 (file)
@@ -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 = {
index 675daed7a85da1d958afe304d468726b9e9de6dc..dfa74c07f7f4fc4039ade1ba0aaf1b77833e3231 100644 (file)
@@ -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):
index 352405ad0c90fea99def7b9b36667c7c31d28d2f..2698b3db37144457febe959b521491fc80a5784b 100644 (file)
@@ -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):
index 34d71a71efef810f8febd7e7458757027e2ea79c..b0a06fa82193421f4f75e5c1f7e886ab58e1e558 100644 (file)
@@ -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()
index a78cc42e4bad3da70d50fae850dbbc9281377452..ace306c93e1c47d41097d078dbcb26812808fa70 100644 (file)
@@ -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')
index 9613404196a990d8dd1d38725f7bf4edc9588859..347de62c87849570508c7d1cb05c45ed8a095ca6 100644 (file)
@@ -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_
index 8793986161a90178977e2457d36ac027da2e1293..60c1770a5a710cb0b7423b7bd038c15771983f7d 100644 (file)
@@ -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()
 
 
index 341eaf77498102982d482ef2c03f4ffdde2116e5..2e45306159d633af1040255d1c52e2491c865ff8 100644 (file)
@@ -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')
index 78a0a7911ce3546662aefa58f6a4184e8084a200..9aa470a304f9b105216b69ff92d5e17a3699107f 100644 (file)
@@ -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)
index a163e7382501e6bdf5062f7d345154d15c9fbaa3..e4543c21f5b4df092b0401c3f4fe3e0bd7715518 100644 (file)
@@ -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."""
index 0d7d36f972658ca8bd7b64242a1988190aa9f5b9..f5b27036d5ce74c8af463535564b6c9d8a1d6f90 100644 (file)
@@ -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."""
index 8f608e75b4756929264b6ef2467cd68f7050263c..5f3fc0035f54252f2593bf213012352b06f95549 100644 (file)
@@ -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)
 
index 6d0a8f31af1876e1a1d2f935daeca27c260f57c9..5b22645960068432003173732d90ff01ebca1702 100644 (file)
@@ -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_ = {}
index 16b838e4c4c7ebf4b1ef90b5aafd79e39a47f952..0eb219f985cf0a15f575cccafd3752f1db8440e2 100644 (file)
@@ -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."""
index 1c5b3471589de01285310e9b995da5bd39e31a1c..3c3d552d345b556dc0077bd782f6258d8d36a218 100644 (file)
@@ -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()
index 05715a52d957307a50411771113204f7292bb122..d36e4934e84364a3f554c5393f80ae633bcdfa09 100644 (file)
@@ -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(
index fee4339c8f68d02a3fde5c1cf56ff52a9aa7f88e..02b0fef1d72fe14e7ac7431616419f183e861602 100644 (file)
@@ -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,
index e1951d17f523c1f51c423c12a62298944bed0411..db786ec21d1aeebf1097945924002bd61da2fe45 100644 (file)
@@ -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
index c3334279aa1de0d2a74daa8245ddb7e823503ff0..d8b48651840f08fd3e6bc6fce4bbaa0a00c51c72 100644 (file)
@@ -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."""
index 0e998f9fb3c01dd30f8da7cbbcdafa1dad78d21a..4849eddf34f24f12e100c3e5befeaef2abfe413a 100644 (file)
@@ -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()
index eb9ea0b15a64fb03e8d8069f2d393dab8669f5b2..c681af827133b373afb9b149f30ae28615f208b4 100644 (file)
@@ -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()
index f6abc5c65e033873b264481b89efb5eb75b438d4..8de601a047adb2fccdfbd2c707a575487ed4dab3 100644 (file)
@@ -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'
index 9bab0361226bbdaaae4188e9bb28c8643da8f924..dee2c2e790d1968f9e712c70195e980728f97b4e 100644 (file)
@@ -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)
 
index 48e8d50bae98cea842e5e0c0fd34d08be5a2e3e6..16f92f088fe72355e3b6e9f33ff60ee75e30f641 100644 (file)
@@ -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()
index 9d7f4079b89a0c0213608522de4268d3725294ca..dc0502abb311c2649bd4e1905b4340254137fba5 100644 (file)
@@ -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)
index de3a60a82ee5dd312b6b3c442e4dc2fc7527a961..3b76c5af37959401b3289b3d2725da3faacce337 100644 (file)
@@ -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',
index 3a7ddd8b941cf4052c5068181d22b85fafcbfda1..6a08e34b292c5afce5d7b4f789af556db723d75e 100644 (file)
@@ -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
index 7c6bd6673707a1e24e84c1eb4a9cd61c8946cc04..c65af6bc58341f0f2fca585a2b42dfb439503d9c 100644 (file)
@@ -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
index 4d02639f65114dd953016a7c4448c4bf91eae6bd..7591f2805c05ba10f04d60e06ef7311e65fdf5de 100644 (file)
@@ -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,
index fdff11b4d7baebea86953975d8fd4ee725978c42..c17e56ab948abb7ae301b5432a1b1fc71453b64b 100644 (file)
@@ -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']
index dcd6025bd3fbc6d9566ac45e47942a5646fb8c2f..94513ee9d1cfe223b2862c11e62d04a3f772d809 100644 (file)
@@ -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()
index 49fba192440b7f4056cb680be9c3bb56588cc316..b98cc29f208209481b1f0e27b9253104bc7789bf 100644 (file)
@@ -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'
index d5eb6a7152ac17f1d858b5132e7f2fb4f27c5277..5e731304de07b6d0ca2f6125fa433af59d072829 100644 (file)
@@ -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."""
index c8962e1e493b7e3d1b46b9e264f93cbce3144750..e10c1a3d7666a5490a6a052347f2cdf268f4d4f3 100644 (file)
@@ -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(
index 1c0bf1f71a0f017dadcafc3ed02ea9fc224daff2..b5344bfd32c21146e08469859499d7699b55d022 100644 (file)
@@ -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."""
index de9e8fbd654cc79f56d2d6ddc75194c0801e928b..15b8e6d4a40b645173dd2cd0958f8c62f4af4e7e 100644 (file)
@@ -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:
index 433e2e208902e46ed08be3317e47c214a2e100ad..0c3a410ea6454b1109912dbfbbf74473babe9cdc 100644 (file)
@@ -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
 
index e46c77d9cb557920d73934f11d8da29de83f2c54..301b5509450ee6f9284156d0e7b7b8d8120b0b00 100644 (file)
@@ -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()
index 924ff447e65c89ee67f489946095ac90e0374b20..d2ff8796e951c4ddb1887e96776fd3448366f5bd 100644 (file)
@@ -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:
index d149e502456d1eb9e3274da55645563ee143e8b0..bbd65928abb2f5526730bfcac96d48d3410fec75 100644 (file)
@@ -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',
index de0dfb7b7f3d89fa991d0b2dd6ae09e1d87b40b2..7c53e6fa7a6a05e3cec52e6edf79ca62db6d5b0e 100644 (file)
@@ -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()
index 627724d54b8c7dd2d93852ef16b65cec03554aac..33aebe977691e491485e712af245f1aeaa7fbfa7 100644 (file)
@@ -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()
index 4e60435178f97e66bfa6dee4309371c4d817e7e9..09d7260625ced494065ffe92863112fb5333ed65 100644 (file)
@@ -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)
index 8c25d7e4ccf4ceee5cccea61eff6961eb0221499..f5ed5bc01b53e4eafe572845e1dc16d8a78eb21f 100644 (file)
@@ -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.'
index 0266d37efc2efb878a2bfe571587be7942eff165..812b797cae72b4f0f3b22dd21236757b7d7b4f1a 100644 (file)
@@ -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 {}
index 15b62f0e66f1199ac99c083e0f43c3e6ca31bd2e..7827a095bd2be8ce7d11f513e883b7a252040280 100644 (file)
@@ -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()
index e544118fee2642c5ba9bda18043e8f971f6588f1..711c287d1982e271211caa53f65e245c3d5cb904 100644 (file)
@@ -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'
index 7da1b08c52084f1f7f57a9d55b0e47f3513111d7..47c376ece8e1a6b8a6d0015b52edf670676e2bec 100644 (file)
@@ -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,
index ac6662b845b2c1a39f974c064b507524100320a6..201e9d74c04e6b1726dba8862c064ce9663217df 100644 (file)
@@ -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()
index 9a6c7e19f65367b66d5d4795819a4545ce98adc5..72d633ce95d82649d53ad53215aba38dae4692e8 100644 (file)
@@ -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):
index 7c84623fc0071e449cc1aa1912302ccfaa10395a..81a6cc0aef046bb53bc834bd2cb7ce3b5a7e56c3 100644 (file)
@@ -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()
index 9cba5ddda6804591e6e3630da70a45767df1eeef..a87cdfd3f9d2192e90b8554817b6a198c0a59c7d 100644 (file)
@@ -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
index eeb7602f85c88d08ad14960dd50c60b05af20126..63cbb4a7552b025786e2fa0dff7b2ae5d2205a43 100644 (file)
@@ -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
index a0b26101b5ce9054ddc20dc0aa34267e92e68b92..54e328e9c9706ce0ad634223b8b3944c8be78563 100644 (file)
@@ -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)
 
index abcb99a7f7468258f298b73073567eaa9379dee4..1baa44dd2540916ec8e49ec54baccc440aa80732 100644 (file)
@@ -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):
index a35b32796e1fec534a89b29c846d3cc637d9d5fb..d5c66cfc35a4db08e7d6629a293e5ca6f7f4ce75 100644 (file)
@@ -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
index c0c01446e4e27c40de33676984b667d710017028..918b8e03a0aff1c5874a082a79adeccd8fde7cbc 100644 (file)
@@ -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()