summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbee_keeper <ricbottomley@gmail.com>2015-10-30 15:27:49 +0000
committerTim Graham <timograham@gmail.com>2015-10-30 13:14:29 -0400
commit06abe84e2070e412cbbb23a4c2fa6a017f64de9b (patch)
treef1fe6b1525b610af12edcebd60f1a2fe8fdf6dcb
parent5adeb410253dcba2215dd8274255a6dd897f14d1 (diff)
[1.8.x] Added class-based view example to RequestFactory example.
Backport of a17216646adaaa909fe52a4e974b56b4f094fc72 from master
-rw-r--r--docs/topics/testing/advanced.txt4
1 files changed, 3 insertions, 1 deletions
diff --git a/docs/topics/testing/advanced.txt b/docs/topics/testing/advanced.txt
index e47666c5b1..c3ec57a936 100644
--- a/docs/topics/testing/advanced.txt
+++ b/docs/topics/testing/advanced.txt
@@ -40,7 +40,7 @@ The following is a simple unit test using the request factory::
from django.contrib.auth.models import AnonymousUser, User
from django.test import TestCase, RequestFactory
- from .views import my_view
+ from .views import MyView, my_view
class SimpleTest(TestCase):
def setUp(self):
@@ -63,6 +63,8 @@ The following is a simple unit test using the request factory::
# Test my_view() as if it were deployed at /customer/details
response = my_view(request)
+ # Use this syntax for class-based views.
+ response = MyView.as_view()(request)
self.assertEqual(response.status_code, 200)
.. _topics-testing-advanced-multidb: