You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defstubout_if_needed(mox_obj, parent_object, attribute):
"""Stubs out the call only if it's not already a mock."""ifnotisinstance(getattr(parent_object, attribute),
(mox.MockAnything, mox.MockObject)):
mox_obj.stubout(parent_object, attribute)
Then if I want to set multiple expectations on the thing that I'm stubbing
out, I can safely call stubout_if_needed(self.mox, module, 'FunctionName')
each time before setting an expectation, and not worry about whether it's
already been stubbed out or not.
Combined with using mox.MoxTestBase which will unset all stubs in self.mox,
this seems pretty safe, because things will succeed whether I create and
use the stub or don't.
The text was updated successfully, but these errors were encountered:
Idea:
Then if I want to set multiple expectations on the thing that I'm stubbing
out, I can safely call stubout_if_needed(self.mox, module, 'FunctionName')
each time before setting an expectation, and not worry about whether it's
already been stubbed out or not.
Combined with using mox.MoxTestBase which will unset all stubs in self.mox,
this seems pretty safe, because things will succeed whether I create and
use the stub or don't.
The text was updated successfully, but these errors were encountered: