-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #12816 -- Added a render() shortcut.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15008 bcc190cf-cafb-0310-a4f2-bffc1f526a37
- Loading branch information
russellm
committed
Dec 21, 2010
1 parent
e77adc9
commit 98004b5
Showing
8 changed files
with
195 additions
and
14 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
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
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
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 +1 @@ | ||
{{ foo }}.{{ bar }}.{{ baz }}.{{ processors }} | ||
{{ foo }}.{{ bar }}.{{ baz }}.{{ STATIC_URL }} |
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from django.conf import settings | ||
from django.test import TestCase | ||
|
||
class ShortcutTests(TestCase): | ||
def setUp(self): | ||
self.old_STATIC_URL = settings.STATIC_URL | ||
self.old_TEMPLATE_CONTEXT_PROCESSORS = settings.TEMPLATE_CONTEXT_PROCESSORS | ||
|
||
settings.STATIC_URL = '/path/to/static/media' | ||
settings.TEMPLATE_CONTEXT_PROCESSORS = ( | ||
'django.core.context_processors.static' | ||
) | ||
|
||
def tearDown(self): | ||
settings.STATIC_URL = self.old_STATIC_URL | ||
settings.TEMPLATE_CONTEXT_PROCESSORS = self.old_TEMPLATE_CONTEXT_PROCESSORS | ||
|
||
def test_render_to_response(self): | ||
response = self.client.get('/views/shortcuts/render_to_response/') | ||
self.assertEquals(response.status_code, 200) | ||
self.assertEquals(response.content, 'FOO.BAR..\n') | ||
self.assertEquals(response['Content-Type'], 'text/html; charset=utf-8') | ||
|
||
def test_render_to_response_with_request_context(self): | ||
response = self.client.get('/views/shortcuts/render_to_response/request_context/') | ||
self.assertEquals(response.status_code, 200) | ||
self.assertEquals(response.content, 'FOO.BAR../path/to/static/media\n') | ||
self.assertEquals(response['Content-Type'], 'text/html; charset=utf-8') | ||
|
||
def test_render_to_response_with_mimetype(self): | ||
response = self.client.get('/views/shortcuts/render_to_response/mimetype/') | ||
self.assertEquals(response.status_code, 200) | ||
self.assertEquals(response.content, 'FOO.BAR..\n') | ||
self.assertEquals(response['Content-Type'], 'application/x-rendertest') | ||
|
||
def test_render(self): | ||
response = self.client.get('/views/shortcuts/render/') | ||
self.assertEquals(response.status_code, 200) | ||
self.assertEquals(response.content, 'FOO.BAR../path/to/static/media\n') | ||
self.assertEquals(response['Content-Type'], 'text/html; charset=utf-8') | ||
|
||
def test_render_with_base_context(self): | ||
response = self.client.get('/views/shortcuts/render/base_context/') | ||
self.assertEquals(response.status_code, 200) | ||
self.assertEquals(response.content, 'FOO.BAR..\n') | ||
self.assertEquals(response['Content-Type'], 'text/html; charset=utf-8') | ||
|
||
def test_render_with_mimetype(self): | ||
response = self.client.get('/views/shortcuts/render/mimetype/') | ||
self.assertEquals(response.status_code, 200) | ||
self.assertEquals(response.content, 'FOO.BAR../path/to/static/media\n') | ||
self.assertEquals(response['Content-Type'], 'application/x-rendertest') | ||
|
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
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