diff --git docs/topics/testing.txt docs/topics/testing.txt
index 4176857..43fa240 100644
|
|
The following is a simple unit test using the request factory::
|
1068 | 1068 | from django.utils import unittest |
1069 | 1069 | from django.test.client import RequestFactory |
1070 | 1070 | |
| 1071 | from .views import my_view |
| 1072 | |
1071 | 1073 | class SimpleTest(unittest.TestCase): |
1072 | 1074 | def setUp(self): |
1073 | 1075 | # Every test needs access to the request factory. |
… |
… |
The following is a simple unit test using the request factory::
|
1081 | 1083 | response = my_view(request) |
1082 | 1084 | self.assertEqual(response.status_code, 200) |
1083 | 1085 | |
| 1086 | The above example uses a functional-based view. If you are using |
| 1087 | :doc:`class-based generic views </topics/class-based-views>`, the ``response`` |
| 1088 | line would be written as follows:: |
| 1089 | |
| 1090 | response = MyClassBasedView.as_view()(request) |
| 1091 | |
1084 | 1092 | TestCase |
1085 | 1093 | -------- |
1086 | 1094 | |