Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.3.X] Changed utils/decorators.py tests to use RequestFactory

Backport of [16272] from trunk. Backported to make the backport of a
bugfix (regression) easier.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16278 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit afa092853fb0fde4abc172f7867121074f260618 1 parent 18ecfad
Luke Plant authored May 25, 2011
26  tests/regressiontests/utils/decorators.py
... ...
@@ -1,19 +1,39 @@
1  
-from django.test import TestCase
  1
+from django.http import HttpResponse
  2
+from django.middleware.doc import XViewMiddleware
  3
+from django.test import TestCase, RequestFactory
  4
+from django.utils.decorators import decorator_from_middleware
  5
+
  6
+
  7
+xview_dec = decorator_from_middleware(XViewMiddleware)
  8
+
  9
+
  10
+@xview_dec
  11
+def xview(request):
  12
+    return HttpResponse()
  13
+
  14
+
  15
+class ClassXView(object):
  16
+    def __call__(self, request):
  17
+        return HttpResponse()
  18
+
  19
+class_xview = xview_dec(ClassXView())
  20
+
2 21
 
3 22
 class DecoratorFromMiddlewareTests(TestCase):
4 23
     """
5 24
     Tests for view decorators created using
6 25
     ``django.utils.decorators.decorator_from_middleware``.
7 26
     """
  27
+    rf = RequestFactory()
8 28
 
9 29
     def test_process_view_middleware(self):
10 30
         """
11 31
         Test a middleware that implements process_view.
12 32
         """
13  
-        self.client.get('/utils/xview/')
  33
+        xview(self.rf.get('/'))
14 34
 
15 35
     def test_callable_process_view_middleware(self):
16 36
         """
17 37
         Test a middleware that implements process_view, operating on a callable class.
18 38
         """
19  
-        self.client.get('/utils/class_xview/')
  39
+        class_xview(self.rf.get('/'))
8  tests/regressiontests/utils/urls.py
... ...
@@ -1,8 +0,0 @@
1  
-from django.conf.urls.defaults import *
2  
-
3  
-import views
4  
-
5  
-urlpatterns = patterns('',
6  
-    (r'^xview/$', views.xview),
7  
-    (r'^class_xview/$', views.class_xview),
8  
-)
17  tests/regressiontests/utils/views.py
... ...
@@ -1,17 +0,0 @@
1  
-from django.http import HttpResponse
2  
-from django.utils.decorators import decorator_from_middleware
3  
-from django.middleware.doc import XViewMiddleware
4  
-
5  
-
6  
-xview_dec = decorator_from_middleware(XViewMiddleware)
7  
-
8  
-def xview(request):
9  
-    return HttpResponse()
10  
-xview = xview_dec(xview)
11  
-
12  
-
13  
-class ClassXView(object):
14  
-    def __call__(self, request):
15  
-        return HttpResponse()
16  
-
17  
-class_xview = xview_dec(ClassXView())
2  tests/urls.py
@@ -29,8 +29,6 @@
29 29
     # admin widget tests
30 30
     (r'widget_admin/', include('regressiontests.admin_widgets.urls')),
31 31
 
32  
-    (r'^utils/', include('regressiontests.utils.urls')),
33  
-
34 32
     # test urlconf for syndication tests
35 33
     (r'^syndication/', include('regressiontests.syndication.urls')),
36 34
 

0 notes on commit afa0928

Please sign in to comment.
Something went wrong with that request. Please try again.