]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove mock.patch.stop from tests that inherit from BaseTestCase
authorrossella <rsblendido@suse.com>
Thu, 10 Apr 2014 09:33:43 +0000 (09:33 +0000)
committerrossella <rsblendido@suse.com>
Thu, 10 Apr 2014 11:40:56 +0000 (11:40 +0000)
The tests that inherit from BaseTestCase don't need to stop their
patches, since this is already done in the base class

Change-Id: Ibb1183e521686d6e948046997b32f4044d91d9e7
Closes-bug: #1305656

29 files changed:
neutron/tests/unit/cisco/test_nexus_plugin.py
neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py
neutron/tests/unit/midonet/test_midonet_driver.py
neutron/tests/unit/mlnx/test_mlnx_comm_utils.py
neutron/tests/unit/services/firewall/drivers/linux/test_iptables_fwaas.py
neutron/tests/unit/services/metering/drivers/test_iptables_driver.py
neutron/tests/unit/test_agent_linux_utils.py
neutron/tests/unit/test_api_v2.py
neutron/tests/unit/test_db_migration.py
neutron/tests/unit/test_db_plugin.py
neutron/tests/unit/test_dhcp_agent.py
neutron/tests/unit/test_extension_ext_gw_mode.py
neutron/tests/unit/test_iptables_firewall.py
neutron/tests/unit/test_linux_daemon.py
neutron/tests/unit/test_linux_external_process.py
neutron/tests/unit/test_linux_interface.py
neutron/tests/unit/test_linux_ip_lib.py
neutron/tests/unit/test_metadata_agent.py
neutron/tests/unit/test_metadata_namespace_proxy.py
neutron/tests/unit/test_neutron_context.py
neutron/tests/unit/test_policy.py
neutron/tests/unit/test_quota_ext.py
neutron/tests/unit/vmware/extensions/test_networkgw.py
neutron/tests/unit/vmware/nsxlib/base.py
neutron/tests/unit/vmware/nsxlib/test_lsn.py
neutron/tests/unit/vmware/test_dhcpmeta.py
neutron/tests/unit/vmware/test_nsx_opts.py
neutron/tests/unit/vmware/test_nsx_sync.py
neutron/tests/unit/vmware/vshield/test_vcns_driver.py

index 395c406431d5e7c9ff7e9a45d5f297018a956843..58bf90f1f2fa9a43140230524517c501e371a869 100644 (file)
@@ -151,7 +151,6 @@ class TestCiscoNexusPlugin(base.BaseTestCase):
         self.patch_obj = mock.patch.dict('sys.modules',
                                          {'ncclient': self.mock_ncclient})
         self.patch_obj.start()
-        self.addCleanup(self.patch_obj.stop)
 
         with mock.patch.object(cisco_nexus_plugin_v2.NexusPlugin,
                                '__init__', new=new_nexus_init):
index f4c5d41c7604beba4096071d3a246af0aec25ba7..fed96aa888c9b391e2193f592b63563edc2641ec 100644 (file)
@@ -105,12 +105,10 @@ class TestLinuxBridgeAgent(base.BaseTestCase):
                              group='SECURITYGROUP')
         self.execute_p = mock.patch.object(ip_lib.IPWrapper, '_execute')
         self.execute = self.execute_p.start()
-        self.addCleanup(self.execute_p.stop)
         self.execute.return_value = '\n'.join(self.LINK_SAMPLE)
         self.get_mac_p = mock.patch('neutron.agent.linux.utils.'
                                     'get_interface_mac')
         self.get_mac = self.get_mac_p.start()
-        self.addCleanup(self.get_mac_p.stop)
         self.get_mac.return_value = '00:00:00:00:00:01'
 
     def test_update_devices_failed(self):
@@ -761,7 +759,6 @@ class TestLinuxBridgeRpcCallbacks(base.BaseTestCase):
 
         self.u_execute_p = mock.patch('neutron.agent.linux.utils.execute')
         self.u_execute = self.u_execute_p.start()
-        self.addCleanup(self.u_execute_p.stop)
 
         class FakeLBAgent(object):
             def __init__(self):
index dc33bcef1457ea6ecc6dc9bdd327dd71cf068260..84c3b62a56cecc33fe2ad659b6276548892b3145 100644 (file)
@@ -45,7 +45,6 @@ class TestDhcpNoOpDriver(base.BaseTestCase):
         self.conf.use_namespaces = True
         instance = mock.patch("neutron.agent.linux.dhcp.DeviceManager")
         self.mock_mgr = instance.start()
-        self.addCleanup(instance.stop)
 
     def test_disable_no_retain_port(self):
         dhcp_driver = driver.DhcpNoOpDriver(self.conf, FakeNetwork())
index 00659e02c105c05bb3ec724513d7a4d21d5f6ed7..75d235759d354463f404a47959903c0d9e4fb1fe 100644 (file)
@@ -31,7 +31,6 @@ class TestRetryDecorator(base.BaseTestCase):
         super(TestRetryDecorator, self).setUp()
         self.sleep_fn_p = mock.patch.object(RetryDecorator, 'sleep_fn')
         self.sleep_fn = self.sleep_fn_p.start()
-        self.addCleanup(self.sleep_fn_p.stop)
 
     def test_no_retry_required(self):
         self.counter = 0
index 85a6c155c0d4abbaa3c545a3d26851705ef20941..f3fba7da584fc4ca697fa7d0365e9f59a5b3fec5 100644 (file)
@@ -43,11 +43,9 @@ class IptablesFwaasTestCase(base.BaseTestCase):
         self.utils_exec_p = mock.patch(
             'neutron.agent.linux.utils.execute')
         self.utils_exec = self.utils_exec_p.start()
-        self.addCleanup(self.utils_exec_p.stop)
         self.iptables_cls_p = mock.patch(
             'neutron.agent.linux.iptables_manager.IptablesManager')
         self.iptables_cls_p.start()
-        self.addCleanup(self.iptables_cls_p.stop)
         self.firewall = fwaas.IptablesFwaasDriver()
 
     def _fake_rules_v4(self, fwid, apply_list):
index f78382dd1d5c0417aeb208317db48e94092ba054..c6131154c7fa6e40487b86f3ef53d103da23e0fb 100644 (file)
@@ -33,11 +33,9 @@ class IptablesDriverTestCase(base.BaseTestCase):
         self.utils_exec_p = mock.patch(
             'neutron.agent.linux.utils.execute')
         self.utils_exec = self.utils_exec_p.start()
-        self.addCleanup(self.utils_exec_p.stop)
         self.iptables_cls_p = mock.patch(
             'neutron.agent.linux.iptables_manager.IptablesManager')
         self.iptables_cls = self.iptables_cls_p.start()
-        self.addCleanup(self.iptables_cls_p.stop)
         self.iptables_inst = mock.Mock()
         self.v4filter_inst = mock.Mock()
         self.v6filter_inst = mock.Mock()
index b0904c3ff248bac93aaca604fde1a81675edd3c1..fd085b8839b19888cf93e7ee48d1140bef831c60 100644 (file)
@@ -29,7 +29,6 @@ class AgentUtilsExecuteTest(base.BaseTestCase):
         open(self.test_file, 'w').close()
         self.mock_popen_p = mock.patch("subprocess.Popen.communicate")
         self.mock_popen = self.mock_popen_p.start()
-        self.addCleanup(self.mock_popen_p.stop)
 
     def test_without_helper(self):
         expected = "%s\n" % self.test_file
index 34bcaa54fd2875b304c7a489b223dc182b5ef51e..23441f0a3c027a3f8b672580e4c31d416f60db0d 100644 (file)
@@ -113,7 +113,6 @@ class APIv2TestBase(base.BaseTestCase):
         instance = self.plugin.return_value
         instance._NeutronPluginBaseV2__native_pagination_support = True
         instance._NeutronPluginBaseV2__native_sorting_support = True
-        self.addCleanup(self._plugin_patcher.stop)
 
         api = router.APIRouter()
         self.api = webtest.TestApp(api)
@@ -1143,7 +1142,6 @@ class SubresourceTest(base.BaseTestCase):
 
         self._plugin_patcher = mock.patch(plugin, autospec=True)
         self.plugin = self._plugin_patcher.start()
-        self.addCleanup(self._plugin_patcher.stop)
 
         router.SUB_RESOURCES['dummy'] = {
             'collection_name': 'dummies',
@@ -1434,7 +1432,6 @@ class ExtensionTestCase(base.BaseTestCase):
 
     def tearDown(self):
         super(ExtensionTestCase, self).tearDown()
-        self._plugin_patcher.stop()
         self.api = None
         self.plugin = None
         # Restore the global RESOURCE_ATTRIBUTE_MAP
index 2cd489a1e5831f1794ababdf763b7c67a2c8f15d..20f97964830c986aee5ec0c25c697bd077fcb47a 100644 (file)
@@ -42,7 +42,6 @@ class TestCli(base.BaseTestCase):
         self.do_alembic_cmd = self.do_alembic_cmd_p.start()
         self.mock_alembic_err = mock.patch('alembic.util.err').start()
         self.mock_alembic_err.side_effect = SystemExit
-        self.addCleanup(self.do_alembic_cmd_p.stop)
 
     def _main_test_helper(self, argv, func_name, exp_args=(), exp_kwargs={}):
         with mock.patch.object(sys, 'argv', argv):
index 4369280200716b63148fd15f0090da52f16ae705..d6bf0c090ce6d68cdd31ba1e70300e9641bcd0da 100644 (file)
@@ -993,20 +993,17 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
             'neutron.api.v2.base.Controller._get_sorting_helper',
             new=_fake_get_sorting_helper)
         helper_patcher.start()
-        try:
-            cfg.CONF.set_default('allow_overlapping_ips', True)
-            with contextlib.nested(self.port(admin_state_up='True',
-                                             mac_address='00:00:00:00:00:01'),
-                                   self.port(admin_state_up='False',
-                                             mac_address='00:00:00:00:00:02'),
-                                   self.port(admin_state_up='False',
-                                             mac_address='00:00:00:00:00:03')
-                                   ) as (port1, port2, port3):
-                self._test_list_with_sort('port', (port3, port2, port1),
-                                          [('admin_state_up', 'asc'),
-                                           ('mac_address', 'desc')])
-        finally:
-            helper_patcher.stop()
+        cfg.CONF.set_default('allow_overlapping_ips', True)
+        with contextlib.nested(self.port(admin_state_up='True',
+                                         mac_address='00:00:00:00:00:01'),
+                               self.port(admin_state_up='False',
+                                         mac_address='00:00:00:00:00:02'),
+                               self.port(admin_state_up='False',
+                                         mac_address='00:00:00:00:00:03')
+                               ) as (port1, port2, port3):
+            self._test_list_with_sort('port', (port3, port2, port1),
+                                      [('admin_state_up', 'asc'),
+                                       ('mac_address', 'desc')])
 
     def test_list_ports_with_pagination_native(self):
         if self._skip_native_pagination:
@@ -1025,17 +1022,14 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
             'neutron.api.v2.base.Controller._get_pagination_helper',
             new=_fake_get_pagination_helper)
         helper_patcher.start()
-        try:
-            cfg.CONF.set_default('allow_overlapping_ips', True)
-            with contextlib.nested(self.port(mac_address='00:00:00:00:00:01'),
-                                   self.port(mac_address='00:00:00:00:00:02'),
-                                   self.port(mac_address='00:00:00:00:00:03')
-                                   ) as (port1, port2, port3):
-                self._test_list_with_pagination('port',
-                                                (port1, port2, port3),
-                                                ('mac_address', 'asc'), 2, 2)
-        finally:
-            helper_patcher.stop()
+        cfg.CONF.set_default('allow_overlapping_ips', True)
+        with contextlib.nested(self.port(mac_address='00:00:00:00:00:01'),
+                               self.port(mac_address='00:00:00:00:00:02'),
+                               self.port(mac_address='00:00:00:00:00:03')
+                               ) as (port1, port2, port3):
+            self._test_list_with_pagination('port',
+                                            (port1, port2, port3),
+                                            ('mac_address', 'asc'), 2, 2)
 
     def test_list_ports_with_pagination_reverse_native(self):
         if self._skip_native_pagination:
@@ -1055,18 +1049,15 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
             'neutron.api.v2.base.Controller._get_pagination_helper',
             new=_fake_get_pagination_helper)
         helper_patcher.start()
-        try:
-            cfg.CONF.set_default('allow_overlapping_ips', True)
-            with contextlib.nested(self.port(mac_address='00:00:00:00:00:01'),
-                                   self.port(mac_address='00:00:00:00:00:02'),
-                                   self.port(mac_address='00:00:00:00:00:03')
-                                   ) as (port1, port2, port3):
-                self._test_list_with_pagination_reverse('port',
-                                                        (port1, port2, port3),
-                                                        ('mac_address', 'asc'),
-                                                        2, 2)
-        finally:
-            helper_patcher.stop()
+        cfg.CONF.set_default('allow_overlapping_ips', True)
+        with contextlib.nested(self.port(mac_address='00:00:00:00:00:01'),
+                               self.port(mac_address='00:00:00:00:00:02'),
+                               self.port(mac_address='00:00:00:00:00:03')
+                               ) as (port1, port2, port3):
+            self._test_list_with_pagination_reverse('port',
+                                                    (port1, port2, port3),
+                                                    ('mac_address', 'asc'),
+                                                    2, 2)
 
     def test_show_port(self):
         with self.port() as port:
@@ -2074,19 +2065,16 @@ class TestNetworksV2(NeutronDbPluginV2TestCase):
             'neutron.api.v2.base.Controller._get_sorting_helper',
             new=_fake_get_sorting_helper)
         helper_patcher.start()
-        try:
-            with contextlib.nested(self.network(admin_status_up=True,
-                                                name='net1'),
-                                   self.network(admin_status_up=False,
-                                                name='net2'),
-                                   self.network(admin_status_up=False,
-                                                name='net3')
-                                   ) as (net1, net2, net3):
-                self._test_list_with_sort('network', (net3, net2, net1),
-                                          [('admin_state_up', 'asc'),
-                                           ('name', 'desc')])
-        finally:
-            helper_patcher.stop()
+        with contextlib.nested(self.network(admin_status_up=True,
+                                            name='net1'),
+                               self.network(admin_status_up=False,
+                                            name='net2'),
+                               self.network(admin_status_up=False,
+                                            name='net3')
+                               ) as (net1, net2, net3):
+            self._test_list_with_sort('network', (net3, net2, net1),
+                                      [('admin_state_up', 'asc'),
+                                       ('name', 'desc')])
 
     def test_list_networks_with_pagination_native(self):
         if self._skip_native_pagination:
@@ -2104,37 +2092,31 @@ class TestNetworksV2(NeutronDbPluginV2TestCase):
             'neutron.api.v2.base.Controller._get_pagination_helper',
             new=_fake_get_pagination_helper)
         helper_patcher.start()
-        try:
-            with contextlib.nested(self.network(name='net1'),
-                                   self.network(name='net2'),
-                                   self.network(name='net3')
-                                   ) as (net1, net2, net3):
-                self._test_list_with_pagination('network',
-                                                (net1, net2, net3),
-                                                ('name', 'asc'), 2, 2)
-        finally:
-            helper_patcher.stop()
+        with contextlib.nested(self.network(name='net1'),
+                               self.network(name='net2'),
+                               self.network(name='net3')
+                               ) as (net1, net2, net3):
+            self._test_list_with_pagination('network',
+                                            (net1, net2, net3),
+                                            ('name', 'asc'), 2, 2)
 
     def test_list_networks_without_pk_in_fields_pagination_emulated(self):
         helper_patcher = mock.patch(
             'neutron.api.v2.base.Controller._get_pagination_helper',
             new=_fake_get_pagination_helper)
         helper_patcher.start()
-        try:
-            with contextlib.nested(self.network(name='net1',
-                                                shared=True),
-                                   self.network(name='net2',
-                                                shared=False),
-                                   self.network(name='net3',
-                                                shared=True)
-                                   ) as (net1, net2, net3):
-                self._test_list_with_pagination('network',
-                                                (net1, net2, net3),
-                                                ('name', 'asc'), 2, 2,
-                                                query_params="fields=name",
-                                                verify_key='name')
-        finally:
-            helper_patcher.stop()
+        with contextlib.nested(self.network(name='net1',
+                                            shared=True),
+                               self.network(name='net2',
+                                            shared=False),
+                               self.network(name='net3',
+                                            shared=True)
+                               ) as (net1, net2, net3):
+            self._test_list_with_pagination('network',
+                                            (net1, net2, net3),
+                                            ('name', 'asc'), 2, 2,
+                                            query_params="fields=name",
+                                            verify_key='name')
 
     def test_list_networks_without_pk_in_fields_pagination_native(self):
         if self._skip_native_pagination:
@@ -2165,16 +2147,13 @@ class TestNetworksV2(NeutronDbPluginV2TestCase):
             'neutron.api.v2.base.Controller._get_pagination_helper',
             new=_fake_get_pagination_helper)
         helper_patcher.start()
-        try:
-            with contextlib.nested(self.network(name='net1'),
-                                   self.network(name='net2'),
-                                   self.network(name='net3')
-                                   ) as (net1, net2, net3):
-                self._test_list_with_pagination_reverse('network',
-                                                        (net1, net2, net3),
-                                                        ('name', 'asc'), 2, 2)
-        finally:
-            helper_patcher.stop()
+        with contextlib.nested(self.network(name='net1'),
+                               self.network(name='net2'),
+                               self.network(name='net3')
+                               ) as (net1, net2, net3):
+            self._test_list_with_pagination_reverse('network',
+                                                    (net1, net2, net3),
+                                                    ('name', 'asc'), 2, 2)
 
     def test_list_networks_with_parameters(self):
         with contextlib.nested(self.network(name='net1',
@@ -3360,21 +3339,18 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
             'neutron.api.v2.base.Controller._get_sorting_helper',
             new=_fake_get_sorting_helper)
         helper_patcher.start()
-        try:
-            with contextlib.nested(self.subnet(enable_dhcp=True,
-                                               cidr='10.0.0.0/24'),
-                                   self.subnet(enable_dhcp=False,
-                                               cidr='11.0.0.0/24'),
-                                   self.subnet(enable_dhcp=False,
-                                               cidr='12.0.0.0/24')
-                                   ) as (subnet1, subnet2, subnet3):
-                self._test_list_with_sort('subnet', (subnet3,
-                                                     subnet2,
-                                                     subnet1),
-                                          [('enable_dhcp', 'asc'),
-                                           ('cidr', 'desc')])
-        finally:
-            helper_patcher.stop()
+        with contextlib.nested(self.subnet(enable_dhcp=True,
+                                           cidr='10.0.0.0/24'),
+                               self.subnet(enable_dhcp=False,
+                                           cidr='11.0.0.0/24'),
+                               self.subnet(enable_dhcp=False,
+                                           cidr='12.0.0.0/24')
+                               ) as (subnet1, subnet2, subnet3):
+            self._test_list_with_sort('subnet', (subnet3,
+                                                 subnet2,
+                                                 subnet1),
+                                      [('enable_dhcp', 'asc'),
+                                       ('cidr', 'desc')])
 
     def test_list_subnets_with_pagination_native(self):
         if self._skip_native_pagination:
@@ -3392,16 +3368,13 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
             'neutron.api.v2.base.Controller._get_pagination_helper',
             new=_fake_get_pagination_helper)
         helper_patcher.start()
-        try:
-            with contextlib.nested(self.subnet(cidr='10.0.0.0/24'),
-                                   self.subnet(cidr='11.0.0.0/24'),
-                                   self.subnet(cidr='12.0.0.0/24')
-                                   ) as (subnet1, subnet2, subnet3):
-                self._test_list_with_pagination('subnet',
-                                                (subnet1, subnet2, subnet3),
-                                                ('cidr', 'asc'), 2, 2)
-        finally:
-            helper_patcher.stop()
+        with contextlib.nested(self.subnet(cidr='10.0.0.0/24'),
+                               self.subnet(cidr='11.0.0.0/24'),
+                               self.subnet(cidr='12.0.0.0/24')
+                               ) as (subnet1, subnet2, subnet3):
+            self._test_list_with_pagination('subnet',
+                                            (subnet1, subnet2, subnet3),
+                                            ('cidr', 'asc'), 2, 2)
 
     def test_list_subnets_with_pagination_reverse_native(self):
         if self._skip_native_sorting:
@@ -3420,17 +3393,14 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
             'neutron.api.v2.base.Controller._get_pagination_helper',
             new=_fake_get_pagination_helper)
         helper_patcher.start()
-        try:
-            with contextlib.nested(self.subnet(cidr='10.0.0.0/24'),
-                                   self.subnet(cidr='11.0.0.0/24'),
-                                   self.subnet(cidr='12.0.0.0/24')
-                                   ) as (subnet1, subnet2, subnet3):
-                self._test_list_with_pagination_reverse('subnet',
-                                                        (subnet1, subnet2,
-                                                         subnet3),
-                                                        ('cidr', 'asc'), 2, 2)
-        finally:
-            helper_patcher.stop()
+        with contextlib.nested(self.subnet(cidr='10.0.0.0/24'),
+                               self.subnet(cidr='11.0.0.0/24'),
+                               self.subnet(cidr='12.0.0.0/24')
+                               ) as (subnet1, subnet2, subnet3):
+            self._test_list_with_pagination_reverse('subnet',
+                                                    (subnet1, subnet2,
+                                                     subnet3),
+                                                    ('cidr', 'asc'), 2, 2)
 
     def test_invalid_ip_version(self):
         with self.network() as network:
index 21b01e4f9487d873bb3e463544eff9a4e66314ae..61b63d4b256d5090981c54c668427c705e740efe 100644 (file)
@@ -488,15 +488,6 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
         )
         self.external_process = self.external_process_p.start()
 
-    def tearDown(self):
-        self.external_process_p.stop()
-        self.call_driver_p.stop()
-        self.cache_p.stop()
-        self.plugin_p.stop()
-        self.mock_makedirs_p.stop()
-        self.mock_init_p.stop()
-        super(TestDhcpAgentEventHandler, self).tearDown()
-
     def _enable_dhcp_helper(self, isolated_metadata=False):
         if isolated_metadata:
             cfg.CONF.set_override('enable_isolated_metadata', True)
@@ -849,11 +840,6 @@ class TestDhcpPluginApiProxy(base.BaseTestCase):
         self.make_msg_p = mock.patch.object(self.proxy, 'make_msg')
         self.make_msg = self.make_msg_p.start()
 
-    def tearDown(self):
-        self.make_msg_p.stop()
-        self.call_p.stop()
-        super(TestDhcpPluginApiProxy, self).tearDown()
-
     def test_get_network_info(self):
         self.call.return_value = dict(a=1)
         retval = self.proxy.get_network_info('netid')
@@ -1118,12 +1104,6 @@ class TestDeviceManager(base.BaseTestCase):
         driver_cls.return_value = self.mock_driver
         iproute_cls.return_value = self.mock_iproute
 
-    def tearDown(self):
-        self.dvr_cls_p.stop()
-        self.device_exists_p.stop()
-        self.iproute_cls_p.stop()
-        super(TestDeviceManager, self).tearDown()
-
     def _test_setup_helper(self, device_exists, net=None, port=None):
         net = net or fake_network
         port = port or fake_port1
index 4e1aa9d5efe0ab1bf5c41f95ced974cb39f30b77..cabb1428e286c4a0834b709a90784597ffd341f9 100644 (file)
@@ -85,7 +85,6 @@ class TestL3GwModeMixin(base.BaseTestCase):
         ctx_patcher = mock.patch('neutron.context', autospec=True)
         mock_context = ctx_patcher.start()
         self.addCleanup(db_api.clear_db)
-        self.addCleanup(ctx_patcher.stop)
         self.context = mock_context.get_admin_context()
         # This ensure also calls to elevated work in unit tests
         self.context.elevated.return_value = self.context
index c1451fb312e9edb38eb955bf81f41a32741f0463..ff2b8106fe3c770c18699a537daf3e1f301dc970 100644 (file)
@@ -42,11 +42,9 @@ class IptablesFirewallTestCase(base.BaseTestCase):
         self.utils_exec_p = mock.patch(
             'neutron.agent.linux.utils.execute')
         self.utils_exec = self.utils_exec_p.start()
-        self.addCleanup(self.utils_exec_p.stop)
         self.iptables_cls_p = mock.patch(
             'neutron.agent.linux.iptables_manager.IptablesManager')
         iptables_cls = self.iptables_cls_p.start()
-        self.addCleanup(self.iptables_cls_p.stop)
         self.iptables_inst = mock.Mock()
         self.v4filter_inst = mock.Mock()
         self.v6filter_inst = mock.Mock()
index 9c40c7b82ccaa9a8040926b166723a4e7c3769eb..12e7d9f351e85973181e4b4f7aac99b9be7dc7e4 100644 (file)
@@ -1,4 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
 #
 # Copyright 2012 New Dream Network, LLC (DreamHost)
 #
@@ -33,12 +32,10 @@ class TestPidfile(base.BaseTestCase):
         super(TestPidfile, self).setUp()
         self.os_p = mock.patch.object(daemon, 'os')
         self.os = self.os_p.start()
-        self.addCleanup(self.os_p.stop)
         self.os.open.return_value = FAKE_FD
 
         self.fcntl_p = mock.patch.object(daemon, 'fcntl')
         self.fcntl = self.fcntl_p.start()
-        self.addCleanup(self.fcntl_p.stop)
         self.fcntl.flock.return_value = 0
 
     def test_init(self):
@@ -132,11 +129,6 @@ class TestDaemon(base.BaseTestCase):
         self.pidfile_p = mock.patch.object(daemon, 'Pidfile')
         self.pidfile = self.pidfile_p.start()
 
-    def tearDown(self):
-        self.pidfile_p.stop()
-        self.os_p.stop()
-        super(TestDaemon, self).tearDown()
-
     def test_init(self):
         d = daemon.Daemon('pidfile')
         self.assertEqual(d.procname, 'python')
index 36146a2ba9e16ded8a9b433c7030c41418b22198..9207e5df025060a988d8cf9158030a1a20f94168 100644 (file)
@@ -27,7 +27,6 @@ class TestProcessManager(base.BaseTestCase):
         super(TestProcessManager, self).setUp()
         self.execute_p = mock.patch('neutron.agent.linux.utils.execute')
         self.execute = self.execute_p.start()
-        self.addCleanup(self.execute_p.stop)
         self.conf = mock.Mock()
         self.conf.external_pids = '/var/path'
 
index 81a6cc0aef046bb53bc834bd2cb7ce3b5a7e56c3..9d278ea5109fe9fab898047242c2d6bd0942bfb9 100644 (file)
@@ -65,13 +65,10 @@ class TestBase(base.BaseTestCase):
         config.register_root_helper(self.conf)
         self.ip_dev_p = mock.patch.object(ip_lib, 'IPDevice')
         self.ip_dev = self.ip_dev_p.start()
-        self.addCleanup(self.ip_dev_p.stop)
         self.ip_p = mock.patch.object(ip_lib, 'IPWrapper')
         self.ip = self.ip_p.start()
-        self.addCleanup(self.ip_p.stop)
         self.device_exists_p = mock.patch.object(ip_lib, 'device_exists')
         self.device_exists = self.device_exists_p.start()
-        self.addCleanup(self.device_exists_p.stop)
 
 
 class TestABCDriver(TestBase):
@@ -377,7 +374,6 @@ class TestMetaInterfaceDriver(TestBase):
         self.conf.register_opts(dhcp.OPTS)
         self.client_cls_p = mock.patch('neutronclient.v2_0.client.Client')
         client_cls = self.client_cls_p.start()
-        self.addCleanup(self.client_cls_p.stop)
         self.client_inst = mock.Mock()
         client_cls.return_value = self.client_inst
 
index 7eb58ad7ba5479182334a7a6c12aacb82d8d25a9..7d56c01b0f4cf713359749570571a4a6c621a917 100644 (file)
@@ -148,7 +148,6 @@ class TestSubProcessBase(base.BaseTestCase):
         super(TestSubProcessBase, self).setUp()
         self.execute_p = mock.patch('neutron.agent.linux.utils.execute')
         self.execute = self.execute_p.start()
-        self.addCleanup(self.execute_p.stop)
 
     def test_execute_wrapper(self):
         ip_lib.SubProcessBase._execute('o', 'link', ('list',), 'sudo')
@@ -200,7 +199,6 @@ class TestIpWrapper(base.BaseTestCase):
         super(TestIpWrapper, self).setUp()
         self.execute_p = mock.patch.object(ip_lib.IPWrapper, '_execute')
         self.execute = self.execute_p.start()
-        self.addCleanup(self.execute_p.stop)
 
     def test_get_devices(self):
         self.execute.return_value = '\n'.join(LINK_SAMPLE)
index 6f7f926acd06042749d52a6c9c07ea28ce644fb1..0e9236ccc32cdef71b284cf5299b35efa5c5f462 100644 (file)
@@ -48,11 +48,9 @@ class TestMetadataProxyHandler(base.BaseTestCase):
         super(TestMetadataProxyHandler, self).setUp()
         self.qclient_p = mock.patch('neutronclient.v2_0.client.Client')
         self.qclient = self.qclient_p.start()
-        self.addCleanup(self.qclient_p.stop)
 
         self.log_p = mock.patch.object(agent, 'LOG')
         self.log = self.log_p.start()
-        self.addCleanup(self.log_p.stop)
 
         self.handler = agent.MetadataProxyHandler(FakeConf)
 
@@ -279,7 +277,6 @@ class TestUnixDomainWSGIServer(base.BaseTestCase):
         super(TestUnixDomainWSGIServer, self).setUp()
         self.eventlet_p = mock.patch.object(agent, 'eventlet')
         self.eventlet = self.eventlet_p.start()
-        self.addCleanup(self.eventlet_p.stop)
         self.server = agent.UnixDomainWSGIServer('test')
 
     def test_start(self):
index 26d7ba9df8413eaef59c52394663ca4d2a89203d..8aafc33a45eba8620e6163f1244dbdb77dca13f1 100644 (file)
@@ -62,7 +62,6 @@ class TestNetworkMetadataProxyHandler(base.BaseTestCase):
         super(TestNetworkMetadataProxyHandler, self).setUp()
         self.log_p = mock.patch.object(ns_proxy, 'LOG')
         self.log = self.log_p.start()
-        self.addCleanup(self.log_p.stop)
 
         self.handler = ns_proxy.NetworkMetadataProxyHandler('router_id')
 
index 937e29666e242cb830be2d96f1e070dcf11bd6c8..ebf30b72cfab0c5f1d4835f548ffa849a9f03393 100644 (file)
@@ -28,7 +28,6 @@ class TestNeutronContext(base.BaseTestCase):
         db_api = 'neutron.db.api.get_session'
         self._db_api_session_patcher = mock.patch(db_api)
         self.db_api_session = self._db_api_session_patcher.start()
-        self.addCleanup(self._db_api_session_patcher.stop)
 
     def test_neutron_context_create(self):
         ctx = context.Context('user_id', 'tenant_id')
index 7c4997630fec2e3a5e209f46fa2e69a0af494db5..22193b5af59c49d05897d637031f25ea5c614851 100644 (file)
@@ -270,7 +270,6 @@ class NeutronPolicyTestCase(base.BaseTestCase):
                                          'init',
                                          new=fakepolicyinit)
         self.patcher.start()
-        self.addCleanup(self.patcher.stop)
         self.addCleanup(remove_fake_resource)
         self.context = context.Context('fake', 'fake', roles=['user'])
         plugin_klass = importutils.import_class(
@@ -279,7 +278,6 @@ class NeutronPolicyTestCase(base.BaseTestCase):
         fake_manager = self.manager_patcher.start()
         fake_manager_instance = fake_manager.return_value
         fake_manager_instance.plugin = plugin_klass()
-        self.addCleanup(self.manager_patcher.stop)
 
     def _test_action_on_attr(self, context, action, attr, value,
                              exception=None):
index 0d88d937177619db244ec222592a91d5aa3bb949..cf11ecb658d01a99b51f75ee887bd2a57762af07 100644 (file)
@@ -78,7 +78,6 @@ class QuotaExtensionTestCase(testlib_api.WebTestCase):
         self.api = webtest.TestApp(ext_middleware)
 
     def tearDown(self):
-        self._plugin_patcher.stop()
         self.api = None
         self.plugin = None
         db.clear_db()
index ae9ccfcf2267d72db81da28825a2d4ac0b447ea0..e437377f3498166a2385f616caa3f4028fae98c0 100644 (file)
@@ -85,7 +85,6 @@ class NetworkGatewayExtensionTestCase(base.BaseTestCase):
 
         _plugin_patcher = mock.patch(plugin, autospec=True)
         self.plugin = _plugin_patcher.start()
-        self.addCleanup(_plugin_patcher.stop)
 
         # Instantiate mock plugin and enable extensions
         manager.NeutronManager.get_plugin().supported_extension_aliases = (
index 2d4fedcb50a966e3114d0b178ee12204771b3928..16281b5ee96a6ff3b8f6c9a2b6a9a67a5bcfcecc 100644 (file)
@@ -53,7 +53,6 @@ class NsxlibTestCase(base.BaseTestCase):
 
         super(NsxlibTestCase, self).setUp()
         self.addCleanup(self.fc.reset_all)
-        self.addCleanup(self.mock_nsxapi.stop)
 
     def _build_tag_dict(self, tags):
         # This syntax is needed for python 2.6 compatibility
@@ -88,4 +87,3 @@ class NsxlibNegativeBaseTestCase(base.BaseTestCase):
 
         super(NsxlibNegativeBaseTestCase, self).setUp()
         self.addCleanup(self.fc.reset_all)
-        self.addCleanup(self.mock_nsxapi.stop)
index 953754928f7da70ad5ee98c78c58ae91a68c6a59..e29afdf10827daac6c0d52fcc58dbad54625a651 100644 (file)
@@ -32,7 +32,6 @@ class LSNTestCase(base.BaseTestCase):
         self.mock_request = self.mock_request_p.start()
         self.cluster = mock.Mock()
         self.cluster.default_service_cluster_uuid = 'foo'
-        self.addCleanup(self.mock_request_p.stop)
 
     def test_service_cluster_None(self):
         self.mock_request.return_value = None
index 5b737bde90352ce437b2b8ada599fcfe216cfd3c..40bf06fbcf13e920a7706bdeb2a2bd8a26c0ab89 100644 (file)
@@ -116,7 +116,6 @@ class MigrationManagerTestCase(base.BaseTestCase):
         self.subnet_id = 'foo_subnet_id'
         self.mock_builder_p = mock.patch.object(self.manager, 'builder')
         self.mock_builder = self.mock_builder_p.start()
-        self.addCleanup(self.mock_builder_p.stop)
 
     def _test_validate(self, lsn_exists=False, ext_net=False, subnets=None):
         network = {'router:external': ext_net}
@@ -268,7 +267,6 @@ class LsnManagerTestCase(base.BaseTestCase):
         self.mock_lsn_api = self.mock_lsn_api_p.start()
         nsx.register_dhcp_opts(cfg)
         nsx.register_metadata_opts(cfg)
-        self.addCleanup(self.mock_lsn_api_p.stop)
 
     def test_lsn_get(self):
         self.mock_lsn_api.lsn_for_network_get.return_value = self.lsn_id
@@ -702,7 +700,6 @@ class PersistentLsnManagerTestCase(base.BaseTestCase):
         self.context = context.get_admin_context()
         self.mock_lsn_api_p = mock.patch.object(lsn_man, 'lsn_api')
         self.mock_lsn_api = self.mock_lsn_api_p.start()
-        self.addCleanup(self.mock_lsn_api_p.stop)
         self.addCleanup(db.clear_db)
 
     def test_lsn_get(self):
index 99b6366a9ee433d89930f46e6aace3d07f3d228f..9a18fcb7877f683bcfc4d194272aa06ac4d6878c 100644 (file)
@@ -82,7 +82,6 @@ class ConfigurationTest(base.BaseTestCase):
         # Avoid runs of the synchronizer looping call
         patch_sync = mock.patch.object(sync, '_start_loopingcall')
         patch_sync.start()
-        self.addCleanup(patch_sync.stop)
 
     def _assert_required_options(self, cluster):
         self.assertEqual(cluster.nsx_controllers, ['fake_1:443', 'fake_2:443'])
@@ -211,7 +210,6 @@ class OldNVPConfigurationTest(base.BaseTestCase):
         # Avoid runs of the synchronizer looping call
         patch_sync = mock.patch.object(sync, '_start_loopingcall')
         patch_sync.start()
-        self.addCleanup(patch_sync.stop)
 
     def _assert_required_options(self, cluster):
         self.assertEqual(cluster.nsx_controllers, ['fake_1:443', 'fake_2:443'])
index 6fbb5d7da6cc9a5b1754083d14639808baec4bee..579317053f715a2af64d9833447cc77482c53ee3 100644 (file)
@@ -298,10 +298,6 @@ class SyncTestCase(base.BaseTestCase):
         mock_nm_get_service_plugins.start()
         super(SyncTestCase, self).setUp()
         self.addCleanup(self.fc.reset_all)
-        self.addCleanup(patch_sync.stop)
-        self.addCleanup(mock_api.stop)
-        self.addCleanup(mock_nm_get_plugin.stop)
-        self.addCleanup(mock_nm_get_service_plugins.stop)
 
     @contextlib.contextmanager
     def _populate_data(self, ctx, net_size=2, port_size=2, router_size=2):
index e49cd2d6cc391581d50321054f01a80f4a810fec..65ece2b399f83e225293a513bfc874ca614cdb95 100644 (file)
@@ -322,7 +322,6 @@ class VcnsDriverTestCase(base.BaseTestCase):
         self.vcns_patch()
 
         self.addCleanup(self.fc.reset_all)
-        self.addCleanup(self.mock_vcns.stop)
 
         self.vcns_driver = vcns_driver.VcnsDriver(self)