title: unittest Mock - patch return value
body: <p>I think I misunderstand how to use mocks for changing a function return value. Here is my test :</p>
  
  <pre><code>from path.to import programme_finder
  @patch('path.to.programme_finder._calc_update_interval')
  def test_refresh_interval(self,method_mock):
      today = datetime.datetime.now()
      dd = datetime.timedelta(millisecond=20)
      earlier_date = today - dd
      #The normal function returns a 5 day interval.
      # For tests I want it down to 20ms
      method_mock.return_value = earlier_date
      #Here I would expect a date object, instead I get MagicMock
      print("Calc returns %s " % programme_finder._calc_update_interval)
      # rest of the test irrelevant 
      self.fail("need to time responce time")
  </code></pre>
  
  <p>What am I doing wrong ? How do I get the <code>programme_finder._calc_update_interval</code> to return my patched <code>datetime</code>?</p>
  
  <p>Tried </p>
  
  <pre><code>assert programme_finder._calc_update_interval == earlier_date
  </code></pre>
  
  <p>as well and it fails.</p>
  
  <pre><code>#programme_finder.py
  def _calc_update_interval():
      today = datetime.datetime.now()
      # The days we want to subtract for today.
      update_interval = current_app.config.get("RESOURCE_UPDATE_INTERVAL")
      dd = datetime.timedelta(days=update_interval)
      # Find which date it was x days ago 
      earlier_date = today - dd
      return earlier_date
  </code></pre>