mirror of https://github.com/django/django.git
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:
parent
eec45e8b71
commit
98dd10e62d
|
@ -1019,12 +1019,14 @@ The request factory
|
||||||
|
|
||||||
.. Class:: RequestFactory
|
.. Class:: RequestFactory
|
||||||
|
|
||||||
The :class:`~django.test.client.RequestFactory` is a simplified
|
.. versionadded:: 1.3
|
||||||
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
|
The :class:`~django.test.client.RequestFactory` shares the same API as
|
||||||
means you can test a view function the same way as you would test any
|
the test client. However, instead of behaving like a browser, the
|
||||||
other function -- as a black box, with exactly known inputs, testing
|
RequestFactory provides a way to generate a request instance that can
|
||||||
for specific outputs.
|
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
|
The API for the :class:`~django.test.client.RequestFactory` is a slightly
|
||||||
restricted subset of the test client API:
|
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()
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_details(self):
|
def test_details(self):
|
||||||
# Issue a GET request.
|
# Create a in instance of a GET request.
|
||||||
request = self.factory.get('/customer/details')
|
request = self.factory.get('/customer/details')
|
||||||
|
|
||||||
# Test my_view() as if it were deployed at /customer/details
|
# Test my_view() as if it were deployed at /customer/details
|
||||||
|
|
Loading…
Reference in New Issue