Merge "Remove function replacement with mock patch"

This commit is contained in:
Jenkins 2014-06-02 01:45:44 +00:00 committed by Gerrit Code Review
commit d720cb5cf6
1 changed files with 3 additions and 6 deletions

View File

@ -42,14 +42,11 @@ class rpcHyperVApiTestCase(base.BaseTestCase):
if rpc_method == 'cast' and method == 'run_instance': if rpc_method == 'cast' and method == 'run_instance':
kwargs['call'] = False kwargs['call'] = False
rpc_method_mock = mock.Mock() with mock.patch.object(rpc, rpc_method) as rpc_method_mock:
rpc_method_mock.return_value = expected_retval rpc_method_mock.return_value = expected_retval
setattr(rpc, rpc_method, rpc_method_mock) retval = getattr(rpcapi, method)(ctxt, **kwargs)
retval = getattr(rpcapi, method)(ctxt, **kwargs)
self.assertEqual(retval, expected_retval) self.assertEqual(retval, expected_retval)
expected_args = [ctxt, topic, expected_msg] expected_args = [ctxt, topic, expected_msg]
for arg, expected_arg in zip(rpc_method_mock.call_args[0], for arg, expected_arg in zip(rpc_method_mock.call_args[0],
expected_args): expected_args):