title: Python pytest mock fails with "assert None" for function call assertions
body: <p>I am trying to mock some calls to boto3 and it looks like the mocked function is returning the correct value, and it look like if I change the assertion so it no longer matches what was passed in the assertion fails because the input parameters do not match, however if I make them match then the assertion fails with:</p>
  <pre><code>E       AssertionError: assert None
  E        +  where None = &lt;bound method wrap_assert_called_with of &lt;MagicMock name='get_item' id='139668501580240'&gt;&gt;(TableName='TEST_TABLE', Key={'ServiceName': {'S': 'Site'}})
  E        +    where &lt;bound method wrap_assert_called_with of &lt;MagicMock name='get_item' id='139668501580240'&gt;&gt; = &lt;MagicMock name='get_item' id='139668501580240'&gt;.assert_called_with
  E        +      where &lt;MagicMock name='get_item' id='139668501580240'&gt; = &lt;botocore.client.DynamoDB object at 0x7f071b8251f0&gt;.get_item
  E        +        where &lt;botocore.client.DynamoDB object at 0x7f071b8251f0&gt; = site_dao.ddb_client
  </code></pre>
  <p>The dynamo DB object is a global variable.</p>
  <pre><code>ddb_client = boto3.client(&quot;dynamodb&quot;)
  
  def query_ddb():
          &quot;&quot;&quot;Query dynamo DB for the current strategy.
  
          Returns:
              strategy (str): The latest strategy from dynamo DB.
  
          &quot;&quot;&quot;
          response = None
  
          try:
              ddb_table = os.environ[&quot;DDB_DA_STRATEGY&quot;]
  
              response = ddb_client.get_item(
                  TableName=ddb_table, Key={&quot;ServiceName&quot;: {&quot;S&quot;: &quot;Site&quot;}}
              )
          except Exception as exception:
              LOGGER.error(exception)
  
              raise ServerException(&quot;The server was unable to process your request.&quot;, [])
  
          return response.get(&quot;Item&quot;).get(&quot;Strategy&quot;).get(&quot;S&quot;)
  </code></pre>
  <p>And my unit test looks like:</p>
  <pre><code>def test_data_access_context_strategy_ddb(mocker):
      object_key = {
          &quot;ServiceName&quot;: {&quot;S&quot;: &quot;Site&quot;}
      }
  
      table_name = &quot;TEST_TABLE&quot;
  
      expected_response = &quot;SqlServer&quot;
  
      os_env = {
          &quot;DDB_DA_STRATEGY&quot;: table_name,
      }
  
      ddb_response = {
          &quot;Item&quot;: {
              &quot;Strategy&quot;: {
                  &quot;S&quot;: expected_response
              }
          }
      }
  
      mocker.patch.dict(os.environ, os_env)
  
      mocker.patch.object(site_dao.ddb_client, &quot;get_item&quot;)
  
      site_dao.ddb_client.get_item.return_value = ddb_response
  
      data_access_context = site_dao.DataAccessContext()
  
      response = data_access_context.query_ddb()
      
      assert response == expected_response
  
      assert site_dao.ddb_client.get_item.assert_called_with(TableName=table_name, Key=object_key)
  </code></pre>
  <p>I cant work out what is going wrong, if I change the expected value for <code>assert_called_with</code>, so for example:</p>
  <pre><code>assert site_dao.ddb_client.get_item.assert_called_with(TableName=&quot;TT&quot;, Key=object_key)
  </code></pre>
  <p>The test fails with:</p>
  <pre><code>E       AssertionError: expected call not found.
  E       Expected: get_item(TableName='TT', Key={'ServiceName': {'S': 'Site'}})
  E       Actual: get_item(TableName='TEST_TABLE', Key={'ServiceName': {'S': 'Site'}})
  E       
  E       pytest introspection follows:
  E       
  E       Kwargs:
  E       assert {'Key': {'Ser... 'TEST_TABLE'} == {'Key': {'Ser...leName': 'TT'}
  E         Omitting 1 identical items, use -vv to show
  E         Differing items:
  E         {'TableName': 'TEST_TABLE'} != {'TableName': 'TT'}
  E         Use -v to get the full diff
  </code></pre>
  <p>So when the expected and actual inputs differ then it fails because of this, however when they are the same and the test should pass it fails because it is as if the function were never even called.</p>