title: Python testing - on-the-fly interactive mock building?
body: <p>I've come up with an idea of on-the-fly interactive mock building. It means that I'd register an object:</p>
  
  <pre><code>session = requests.Session()
  mock_building.start(session)
  </code></pre>
  
  <p>and then when I invoke:</p>
  
  <pre><code>session.get("http://stackoverflow.com")
  </code></pre>
  
  <p>It would make a request to stackoverflow as usual and save Response (somewhere).</p>
  
  <p>Then I'd make something like:</p>
  
  <pre><code>mock_building.save(session, "stackoverflow_session.dat")  # pickling?
  </code></pre>
  
  <p>And later (in next execution) I'd do:</p>
  
  <pre><code>session = mock_building.load("stackoverflow_session.dat") 
  </code></pre>
  
  <p>And this time:</p>
  
  <pre><code>session.get("http://stackoverflow.com")  # overloaded __getattr__?
  </code></pre>
  
  <p>Would give me exactly the same Response but without request to stackoverflow.</p>
  
  <p>Is this thing possible? Please note I do not want to limit myself to requests module, I'd be great for developing/testing in general case (for example when a program raises an Exception on the 300th line and getting there takes a lot of time). Or would it be not?</p>