title: Can I add an instance method to a Python "Mock" object?
body: <p>I would like to create a <code>mock.Mock()</code> object, then add a method called <code>session</code> that acts like an instance method, which is passed a <code>self</code> reference to the mock object, allowing the method to add state to the mock object. Is this possible (without manually using <code>types.MethodType</code>, e.g., using mock's built-in API), or should I just find a way around it?</p>
  
  <p>Note, I found <a href="https://stackoverflow.com/questions/4008681/how-to-mock-an-instance-method-of-an-already-mocked-object">this question</a>, which is for Ruby and seems to cover something similar, if not the same thing. Unfortunately, I don't know Ruby very well at all.</p>