title: What is the difference between mocking and monkey patching?
body: <p>I work with python and I'm a bit new to testing. I often see tests replacing an external dependency with a local method like so:</p>
  <pre><code>import some_module
  
  def get_file_data():
    return &quot;here is the pretend file data&quot;
  
  some_module.get_file_data = get_file_data
  
  # proceed to test
  </code></pre>
  <p>I see this referred to as &quot;monkey patching&quot; as in the <a href="https://stackoverflow.com/questions/5626193/what-is-a-monkey-patch">question</a>. I also see the word &quot;mock&quot; being used a lot alongside &quot;monkey patching&quot; or in what seem to be very similar scenarios.</p>
  <p>Is there any difference between the two concepts?</p>