title: pytest-mock assert_called_with failed for class function
body: <p>I am planning to use pytest and pytest-mock for validating the Python code. Being a newbie, wrote a sample code to validate the mock on class and seeing failure. I am wondering what went wrong.</p>
  
  <p>src/main.py  </p>
  
  <pre><code>class Main(object):
      def __init__(self, my_var=None):
          self.var = my_var
  
      def internal_func(self, var=10):
          my_var = var + 20
          return my_var
  
      def test_func(self):
          val = self.internal_func(20)
          return val + 40
  </code></pre>
  
  <p>tests/test_main.py</p>
  
  <pre><code>    import pytest
      from pytest_mock import mocker
      from src.main import Main
  
      def new_func(cls, *args, **kwargs):
          return 2
  
      def test_main_mock(mocker):
          mocker.patch.object(Main, 'internal_func')
          val = Main().test_func()
          assert Main.internal_func.assert_called_with(20)
  </code></pre>
  
  <p>It fails with the following error</p>
  
  <pre><code>    ======================================================================================== FAILURES ========================================================================================
      _____________________________________________________________________________________ test_main_mock _____________________________________________________________________________________
  
      mocker = &lt;pytest_mock.MockFixture object at 0x7f34f490d8d0&gt;
  
          def test_main_mock(mocker):
              mocker.patch.object(Main, 'internal_func')
              main = Main()
              val = main.test_func()
          #    assert val == 80
      &gt;       assert Main.internal_func.assert_called_with(20)
      E       AssertionError: assert None
      E        +  where None = &lt;bound method MagicMock.wrap_assert_called_with of &lt;MagicMock name='internal_func' id='139865418160784'&gt;&gt;(20)
      E        +    where &lt;bound method MagicMock.wrap_assert_called_with of &lt;MagicMock name='internal_func' id='139865418160784'&gt;&gt; = &lt;MagicMock name='internal_func' id='139865418160784'&gt;.assert_called_with
      E        +      where &lt;MagicMock name='internal_func' id='139865418160784'&gt; = Main.internal_func
  
      tests/test_main.py:13: AssertionError
  </code></pre>