title: pytest : Cannot mock __init__ of my class
body: <p>I am having a custom <code>Db</code> class, which has the basic operations. I am trying to write tests around it - on the <code>__init__</code> of my class I am connecting to actual db which I want to avoid ( since I am just writing unit tests, no need to connect to the actual db ).</p>
  
  <p>This is my code :</p>
  
  <pre><code>@mock.patch( 'mydb.Db' )
  @pytest.mark.parametrize( "input,expected", [
      (
          {
              'key'   : "x" ,
              'value' : 5   ,
          } , 
          [  "x = 5" ]
      ) ,
      ])
  def test_where_statement( mock_db, input, expected):
      mock_db.__init__.return_value = None
      assert expected == mock_db.where( input[ "key"] , input[ "value" ] )._condition_list
  </code></pre>
  
  <p>It fails on the line where I set the return_value to None - issue is :</p>
  
  <pre><code>    def test_where_statement( mock_db, input, expected):
  &gt;       mock_db.__init__.return_value = None
  E       AttributeError: 'instancemethod' object has no attribute 'return_value'
  </code></pre>
  
  <p>I want to mock only the init function and then be able to run the where function ( which builds the where statement of my query for example ).</p>
  
  <p>What am I missing?</p>