Loading docs/topics/testing.txt +9 −7 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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 Loading Loading
docs/topics/testing.txt +9 −7 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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 Loading