title: Mocking a class: Mock() or patch()?
body: <p>I am using <a href="http://www.voidspace.org.uk/python/mock/index.html">mock</a> with Python and was wondering which of those two approaches is better (read: more pythonic). </p>
  
  <p><strong>Method one</strong>:  Just create a mock object and use that. The code looks like:</p>
  
  <pre><code>def test_one (self):
      mock = Mock()
      mock.method.return_value = True 
      self.sut.something(mock) # This should called mock.method and checks the result. 
      self.assertTrue(mock.method.called)
  </code></pre>
  
  <p><strong>Method two</strong>:  Use patch to create a mock.  The code looks like:</p>
  
  <pre><code>@patch("MyClass")
  def test_two (self, mock):
      instance = mock.return_value
      instance.method.return_value = True
      self.sut.something(instance) # This should called mock.method and checks the result. 
      self.assertTrue(instance.method.called)
  </code></pre>
  
  <p>Both methods do the same thing.  I am unsure of the differences. </p>
  
  <p>Could anyone enlighten me?</p>