I came across this while doing unittest, I am curious to know what is the difference between the below two ?
self.monkeyPatch(module, 'myFunc', lambda n: someObject)
and
mox.StubOutWithMock(module, 'myFunc')
module.myFunc(n).AndReturn(someObject)
where myFunc is public function in the module, n is argument passed to myFunc and it returns someObject.
Just different libraries/implementations of monkey patching.
Monkeypatching can be done without any library, but it has a number of repetitive (and kind of ugly) things it needs to do, so if you start to implement it yourself, you end up creating helpers to help with this. And naturally there a couple ready-to-use libraries to do it for you.