Clarified the text and example describing the RequestFactory. Thanks to Alex for the feedback.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14192 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2010-10-12 23:55:38 +00:00
parent eec45e8b71
commit 98dd10e62d
1 changed files with 9 additions and 7 deletions

View File

@ -1019,12 +1019,14 @@ The request factory
.. Class:: RequestFactory
The :class:`~django.test.client.RequestFactory` is a simplified
version of the test client that provides a way to generate a request
instance that can be used as the first argument to any view. This
means you can test a view function the same way as you would test any
other function -- as a black box, with exactly known inputs, testing
for specific outputs.
.. versionadded:: 1.3
The :class:`~django.test.client.RequestFactory` shares the same API as
the test client. However, instead of behaving like a browser, the
RequestFactory provides a way to generate a request instance that can
be used as the first argument to any view. This means you can test a
view function the same way as you would test any other function -- as
a black box, with exactly known inputs, testing for specific outputs.
The API for the :class:`~django.test.client.RequestFactory` is a slightly
restricted subset of the test client API:
@ -1052,7 +1054,7 @@ The following is a simple unit test using the request factory::
self.factory = RequestFactory()
def test_details(self):
# Issue a GET request.
# Create a in instance of a GET request.
request = self.factory.get('/customer/details')
# Test my_view() as if it were deployed at /customer/details