yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #08691
[Bug 1263602] Re: Do not use contextlib.nested if only mock one function
** Changed in: nova
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1263602
Title:
Do not use contextlib.nested if only mock one function
Status in OpenStack Compute (Nova):
Fix Released
Bug description:
There are some test cases in test_compute_mgr.py using
contextlib.nested to mock up functions even there is only one
function.
We should use mock.patch.object directly if only mock one function.
def test_init_instance_sets_building_error(self):
with contextlib.nested( <<<<< No need use nested here
mock.patch.object(self.compute, '_instance_update')
) as (
_instance_update,
):
instance = instance_obj.Instance(self.context)
instance.uuid = 'foo'
instance.vm_state = vm_states.BUILDING
instance.task_state = None
self.compute._init_instance(self.context, instance)
call = mock.call(self.context, 'foo',
task_state=None,
vm_state=vm_states.ERROR)
_instance_update.assert_has_calls([call])
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1263602/+subscriptions
References