From 4f96dd72e37ddcdbf756d711537a8b025183b73c Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Thu, 29 May 2014 20:49:48 -0700 Subject: [PATCH] Remove unnecessary MagicMocks in cisco unit tests Two patches that just return static data never have assertions made on the MagicMocks generated. This replaces the magicmocks with lambdas to make the code easier to read and to get a minor performance gain. Change-Id: I064c57a66a0f7a8e3080f39cf48bd4b67cf304e3 Partial-Bug: #1316401 --- neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py b/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py index 12973a383..ad45b0910 100644 --- a/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py +++ b/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py @@ -201,17 +201,13 @@ class N1kvPluginTestCase(test_plugin.NeutronDbPluginV2TestCase): # in the background. # Return a dummy VSM IP address - get_vsm_hosts_patcher = mock.patch(n1kv_client.__name__ + - ".Client._get_vsm_hosts") - fake_get_vsm_hosts = get_vsm_hosts_patcher.start() - fake_get_vsm_hosts.return_value = ["127.0.0.1"] + mock.patch(n1kv_client.__name__ + ".Client._get_vsm_hosts", + new=lambda self: "127.0.0.1").start() # Return dummy user profiles - get_cred_name_patcher = mock.patch(cdb.__name__ + - ".get_credential_name") - fake_get_cred_name = get_cred_name_patcher.start() - fake_get_cred_name.return_value = {"user_name": "admin", - "password": "admin_password"} + mock.patch(cdb.__name__ + ".get_credential_name", + new=lambda self: {"user_name": "admin", + "password": "admin_password"}).start() n1kv_neutron_plugin.N1kvNeutronPluginV2._setup_vsm = _fake_setup_vsm -- 2.45.2