From: Russell Bryant Date: Tue, 25 Nov 2014 18:06:46 +0000 (+0000) Subject: Drop sudo requirement from a unit test X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c8298b6f98c19cfd24cbd4e95cc2f6c6e840d826;p=openstack-build%2Fneutron-build.git Drop sudo requirement from a unit test I noticed while working on some other stuff that a unit test was prompting me for my sudo password. I narrowed it down to the offending test case and fixed it by mocking out the execute util, as is done in several other places in these tests. Change-Id: I93c6cdb8a26d3be5df5386091dc70a240ab7c190 Closes-bug: #1396276 --- diff --git a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py index c39f1cdc1..3874a3c43 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py @@ -565,10 +565,12 @@ class TestOvsNeutronAgent(base.BaseTestCase): # Raise a timeout every time until we give up, currently 5 tries self._setup_for_dvr_test() self.agent.dvr_agent.dvr_mac_address = None - with mock.patch.object(self.agent.dvr_agent.plugin_rpc, - 'get_dvr_mac_address_by_host', - side_effect=raise_timeout): - + with contextlib.nested( + mock.patch.object(self.agent.dvr_agent.plugin_rpc, + 'get_dvr_mac_address_by_host', + side_effect=raise_timeout), + mock.patch.object(utils, "execute"), + ) as (rpc_mock, execute_mock): self.agent.dvr_agent.get_dvr_mac_address() self.assertIsNone(self.agent.dvr_agent.dvr_mac_address) self.assertFalse(self.agent.dvr_agent.in_distributed_mode())