Create a functioning Response object
<p>For testing purposes I'm trying to create a Response() object in python but it proves harder then it sounds.</p>

<p>i tried this:</p>

<pre><code>from requests.models import Response

the_response = Response()
the_response.code = "expired"
the_response.error_type = "expired"
the_response.status_code = 400
</code></pre>

<p>but when I attempted <code>the_response.json()</code> i got an error because the function tries to get <code>len(self.content)</code> and <code>a.content</code> is null.
So I set <code>a._content = "{}"</code> but then I get an encoding error, so I have to change <code>a.encoding</code>, but then it fails to decode the content....
this goes on and on. Is there a simple way to create a Response object that's functional and has an arbitrary status_code and content?</p>