title: How to patch an asynchronous class method?
body: <p>I'm working on the following problem, I have a class, an asynchronous  method of which I want to mock patch:</p>
  
  <pre><code>class ExampleClass:
      async def asy_method(self, param):
          return await some_coroutine(self, param)
  
  example_instance = ExampleClass()
  </code></pre>
  
  <p>I want to patch specifically only calls like</p>
  
  <pre><code>await example_instance.asy_method('test_param')
  </code></pre>
  
  <p>Normally I'd use </p>
  
  <pre><code>mocker.patch('ExampleClass.asy_method', new_callable=AsyncMock)
  </code></pre>
  
  <p>where mocker is the pytest-mock plugin fixture and AsyncMock has the form</p>
  
  <pre><code>class AsyncMock(mock.MagicMock):
      async def __call__(self, *args, **kwargs):
           return super(AsyncMock, self).__call__(*args, **kwargs)
  </code></pre>
  
  <p>which would give me a Mock object that behaves like a coroutine on call. 
  The problem is, that I want to have access to the <code>self</code> attribute that is passed to the method. <code>self</code> is only passed to the mock object if you set 
  <code>autospec=True</code> though (see also <a href="https://docs.python.org/3/library/unittest.mock-examples.html#mocking-unbound-methods" rel="noreferrer">Python Doc on patching unbound methods</a>), which you can't use together with <code>new_callable</code>.</p>
  
  <p>Does anyone have an idea how to resolve this?</p>