title: Mocking side_effect while autospeccing gives the function additional argument
body: <p>So the example code is very basic:</p>
  
  <pre><code>@mock.patch.object(BookForm, 'is_valid')
  def test_edit(self, mocked_is_valid):
      create_superuser()
      self.client.login(username="test", password="test")
  
      book = Book()
      book.save()
  
      mocked_is_valid.side_effect = lambda: True
  
      self.client.post(reverse('edit', args=[book.pk]), {})
  </code></pre>
  
  <p>This works well. But adding autospec keyword to the mock:</p>
  
  <pre><code>@mock.patch.object(BookForm, 'is_valid', autospec=True)
  </code></pre>
  
  <p>causes additional argument to be passed to the <code>side_effect</code> callable, which obviously results in error:</p>
  
  <pre><code>TypeError: &lt;lambda&gt;() takes 0 positional arguments but 1 was given
  </code></pre>
  
  <p>What I don't uderstand, is why autospeccing gives additional argument. I've read the <a href="https://docs.python.org/3/library/unittest.mock.html">docs</a>, but still can't find the explanation of this behaviour.</p>
  
  <p>Theoretically, it's written that </p>
  
  <blockquote>
    <p>In addition mocked functions / methods have the same call signature as the original so they raise a TypeError if they are called incorrectly.</p>
  </blockquote>
  
  <p>so it'd be okay (<code>is_valid</code> has <code>self</code> argument, which is probably what is being passed here), but on the other hand it's also written about <code>side_effect</code> that</p>
  
  <blockquote>
    <p>The function is called with the same arguments as the mock, and unless it returns DEFAULT, the return value of this function is used as the return value.</p>
  </blockquote>
  
  <p>So as far as I understand, <code>side_effect</code> should be called with the <code>self</code> argument even without autospeccing. But it is not.</p>
  
  <blockquote>
    <p>is called with the same arguments as the mock</p>
  </blockquote>
  
  <pre><code>if form.is_valid():  # the mock is_valid is called with the self argument, isn't it?
  </code></pre>
  
  <p>So if someone could explain it to me, preferably quoting the docs, I'd be thankful.</p>