<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: httprequest</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/httprequest.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2008-08-12T12:40:01+00:00</updated><author><name>Simon Willison</name></author><entry><title>Django snippets: RequestFactory</title><link href="https://simonwillison.net/2008/Aug/12/django/#atom-tag" rel="alternate"/><published>2008-08-12T12:40:01+00:00</published><updated>2008-08-12T12:40:01+00:00</updated><id>https://simonwillison.net/2008/Aug/12/django/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.djangosnippets.org/snippets/963/"&gt;Django snippets: RequestFactory&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
I’ve been wanting this for ages; when I finally got around to writing it it turned out to only be a dozen or so lines of code. Makes it easy to create mock request objects in Django, which you can then use for testing view functions directly (bypassing the current test client mechanism which requires views to be assigned to a URLconf before they can be tested).


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/code"&gt;code&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/httprequest"&gt;httprequest&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/requestfactory"&gt;requestfactory&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/testing"&gt;testing&lt;/a&gt;&lt;/p&gt;



</summary><category term="code"/><category term="django"/><category term="httprequest"/><category term="python"/><category term="requestfactory"/><category term="testing"/></entry></feed>