Remove mock.patch.stop from tests that inherit from BaseTestCase

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
This commit is contained in:
rossella 2014-04-10 09:33:43 +00:00
parent 7cbe7ce27c
commit 1e0ea5217a
29 changed files with 91 additions and 196 deletions

View 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):

View 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):

View 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())

View 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

View 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):

View 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()

View 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

View 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

View 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):

View 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:

View 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

View 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

View 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()

View 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')

View 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'

View 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

View 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)

View 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):

View 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')

View 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')

View 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):

View 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()

View 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 = (

View 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)

View 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

View 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):

View 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'])

View 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):

View 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)