title: Stubbing vs Mocking in Python
body: <p>I'm want to mock or stub a function for testing. Not sure if I have the terminology right so correct me if I'm wrong, but I understand a mock as using a mocking library similar to <a href="https://docs.python.org/3/library/unittest.mock.html" rel="nofollow noreferrer">unittest.mock</a> to create a fake object and has expectations about what parameters it will receive and what what it will return, etc. This seems a bit of overkill to me since all I want is the mocked/stubbed method to do is return a set value.</p>
  
  <p>I think of stubbing as just 'mocking without a library', like the answer to <a href="https://stackoverflow.com/q/3909942/1393498">this question</a>. From what I can see, this is exactly what I want. It's light and simple and you don't have to mess around with all the options of mocking for the simple cases.</p>
  
  <p>My question is, <strong>is it safe to do this?</strong> The question above seems to be overwriting the in memory representation of a method, and it just doesn't seem right. Is this accepted by the python community? Or is it encouraged to use a proper mocking library all the time?</p>
  
  <p><strong>EDIT</strong> What kind of horrible things would happen if you didn't reassign the method in the finally block, as the linked answer states?</p>