title: Python function not using the mocked object
body: <p>Coming from a PHP background I have encountered the following issue in writing Python unit tests:</p>
  
  <p>I have function foo that uses a Client object in order to get a response from some other API:</p>
  
  <pre><code>from xxxx import Client
  def foo (some_id, token):
      path = 'some/api/path'
      with Client.get_client_auth(token) as client:
          response = client.get(path,params).json()
          results = list(response.keys())
      .............
  </code></pre>
  
  <p>For this I have created the following unit test in another python file.</p>
  
  <pre><code>from yyyy import foo
  class SomethingTestCase(param1, param2):
      def test_foo(self):
          response = [1,2,3]
          with patch('xxxx.Client') as MockClient:
              instance = MockClient.return_value
              instance.get.return_value = response
          result = foo(1,self.token)
          self.assertEqual(response,result)
  </code></pre>
  
  <p>I don't understand why foo isn't using the mocked [1,2,3] list and instead tries to connect to the actual API path in order to pull the real data.</p>
  
  <p>What am I missing?</p>