How to use Mox to mock a module function and allow it to be called in almost any way

I have a function A that calls another function B several times. I want to mock B so that any number of calls that have the correct number of arguments, regardless of the value, will return a fixed area and be considered correct.

If or how many times a function is called, it is not part of the specification.

+4
source share
2 answers

Cut B usually ....

Assuming B takes 2 arguments and should return 'foo':

B(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn('foo') 
+8
source
 def B(*args, **kwds): return 'fixed value' 
+1
source

All Articles