title: Checking whether function has been called multiple times with different parameters
body: <p>Assume we have a function <code>f(x,y)</code> and another function</p>
  
  <pre><code>def g():
         # ...
         f(i,j) # i,j vary and f is called multiple times
         # ...
  </code></pre>
  
  <p>We want to write a Unit test that checks whether <code>f</code> is called the number of times and with the right parameters.</p>
  
  <pre><code>def test_g():
        with patch('mymodule.f') as function:
            assert function.gacs.call_count == correct_no_calls
  </code></pre>
  
  <p>There is</p>
  
  <pre><code>function.assert_called_with(...)
  </code></pre>
  
  <p>but this only refers to the last call. So assuming <code>g</code> calls <code>f(1,2)</code> and then <code>f(2,3)</code>, <code>function.assert_called_with(1,2)</code> is <code>False</code>.</p>
  
  <p>Furthermore, there is</p>
  
  <pre><code>function.call_args_list
  </code></pre>
  
  <p>which yields a list of <code>call</code> objects with the right parameters. Comparing this list to <code>call</code> object that we create in the unit test feels like a very nasty thing to do. <code>call</code> seems like an internal class of the mock library.</p>
  
  <p>Is there a better way to do this? I use this set-up to test parallel execution of an <code>apply</code> function.</p>