title: How to get the call count using Mock @patch?
body: <p>I am writing a unit test for some library we are working on. This library makes use of <code>requests.post()</code> to perform POST HTTP requests to an external server.</p>
  
  <p>Inside my UT, I obviously don't want to contact the real server but to mock the response.</p>
  
  <p>To do that, I wrote a function that goes like:</p>
  
  <pre><code>def mocked_post(url, headers, data, **kwargs):
      response = Mock()
  
      # Some logic, irrelevant here.
  
      return response
  </code></pre>
  
  <p>And I patched this function around my unit test class:</p>
  
  <pre><code>@patch('mylib.requests.post', mocked_post)
  class MyTest(TestCase):
  
      def test_foo(self):
          # Some test logic
  </code></pre>
  
  <p>This is working perfectly.</p>
  
  <p>Now I'd like to get the number of calls to my mocked function. I tried <code>mocked_post.call_count</code> but that doesn't exist. I tried to find this property on a lot of different objects (including <code>mylib.requests.post</code>) but no luck so far.</p>
  
  <p>How can I access the <code>call_count</code> for this mocked function ?</p>