title: Python - why mock patch decorator does not pass the mocked object to the test function when `new` argument is not DEFAULT
body: <p>in Python 3.6, I use <code>unittest.mock.patch</code> to patch a function like this:</p>
  
  <pre><code>class SampleTest(TestCase):
  
      @mock.patch('some_module.f')
      def test_f(self, mocked_f):
          f()
          mocked_f.assert_called()
  
  </code></pre>
  
  <p>This passes a <code>mock.MagicMock()</code> as <code>mocked_f</code> and everything works fine. However, when I want to use a custom mock object instead of the default <code>mock.MagicMock()</code> using <code>new</code> argument, the patch decorator does not pass the mocked object to the <code>test_f</code> method. Running this code will raise a <code>TypeError</code>:</p>
  
  <pre><code>class SampleTest(TestCase):
  
      @mock.patch('some_module.f', new=lambda: 8)
      def test_f(self, mocked_f):
          f()
          mocked_f.assert_called()
  </code></pre>
  
  <pre><code>TypeError: test_f() missing 1 required positional argument: 'mocked_f'
  </code></pre>
  
  <p>My question is: why is this happening? </p>