Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
1 parent
18ecfad
commit afa0928
Showing
4 changed files
with
23 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,39 @@ | ||
from django.test import TestCase | ||
from django.http import HttpResponse | ||
from django.middleware.doc import XViewMiddleware | ||
from django.test import TestCase, RequestFactory | ||
from django.utils.decorators import decorator_from_middleware | ||
|
||
|
||
xview_dec = decorator_from_middleware(XViewMiddleware) | ||
|
||
|
||
@xview_dec | ||
def xview(request): | ||
return HttpResponse() | ||
|
||
|
||
class ClassXView(object): | ||
def __call__(self, request): | ||
return HttpResponse() | ||
|
||
class_xview = xview_dec(ClassXView()) | ||
|
||
|
||
class DecoratorFromMiddlewareTests(TestCase): | ||
""" | ||
Tests for view decorators created using | ||
``django.utils.decorators.decorator_from_middleware``. | ||
""" | ||
rf = RequestFactory() | ||
|
||
def test_process_view_middleware(self): | ||
""" | ||
Test a middleware that implements process_view. | ||
""" | ||
self.client.get('/utils/xview/') | ||
xview(self.rf.get('/')) | ||
|
||
def test_callable_process_view_middleware(self): | ||
""" | ||
Test a middleware that implements process_view, operating on a callable class. | ||
""" | ||
self.client.get('/utils/class_xview/') | ||
class_xview(self.rf.get('/')) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters