Merge "Improve usage of MagicMocks in ML2 and L3 tests"
This commit is contained in:
@@ -38,11 +38,9 @@ class RpcApiTestCase(base.BaseTestCase):
|
||||
if rpc_method == 'cast' and method == 'run_instance':
|
||||
kwargs['call'] = False
|
||||
|
||||
rpc_method_mock = mock.Mock()
|
||||
rpc_method_mock.return_value = expected_retval
|
||||
setattr(rpc, rpc_method, rpc_method_mock)
|
||||
|
||||
retval = getattr(rpcapi, method)(ctxt, **kwargs)
|
||||
with mock.patch.object(rpc, rpc_method) as rpc_method_mock:
|
||||
rpc_method_mock.return_value = expected_retval
|
||||
retval = getattr(rpcapi, method)(ctxt, **kwargs)
|
||||
|
||||
self.assertEqual(retval, expected_retval)
|
||||
|
||||
|
||||
@@ -1897,9 +1897,8 @@ class L3BaseForIntTests(test_db_plugin.NeutronDbPluginV2TestCase):
|
||||
ext_mgr = ext_mgr or L3TestExtensionManager()
|
||||
|
||||
if self.mock_rescheduling:
|
||||
rescheduling_patcher = mock.patch(
|
||||
'%s._check_router_needs_rescheduling' % plugin)
|
||||
rescheduling_patcher.start().return_value = False
|
||||
mock.patch('%s._check_router_needs_rescheduling' % plugin,
|
||||
new=lambda *a: False).start()
|
||||
|
||||
super(L3BaseForIntTests, self).setUp(plugin=plugin, ext_mgr=ext_mgr,
|
||||
service_plugins=service_plugins)
|
||||
|
||||
Reference in New Issue
Block a user