diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2013-09-06 15:06:57 -0700 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2013-09-06 17:11:07 -0500 |
| commit | b917458f4752e98dc7866261f40e296de3701130 (patch) | |
| tree | b74c9409c8afde9bcf392aa63be6fece56fb26db /tests/view_tests | |
| parent | 2ab2d0fb255377a1630e05696b61a7d2e9c436bd (diff) | |
Merge pull request #1579 from ianawilson/ticket_21058
[1.6.x] Fixed #21058 -- Fixed debug view blowing up when no template is provided to the template rendering functions.
Assistance on this commit from @jambonrose.
Backport of 122020fdb93980df850ae02f61d97da27e2cb515 from master.
Diffstat (limited to 'tests/view_tests')
| -rw-r--r-- | tests/view_tests/tests/test_debug.py | 7 | ||||
| -rw-r--r-- | tests/view_tests/urls.py | 1 | ||||
| -rw-r--r-- | tests/view_tests/views.py | 5 |
3 files changed, 13 insertions, 0 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index f686eee0e0..0baddd2bf8 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -12,6 +12,7 @@ from tempfile import NamedTemporaryFile, mkdtemp, mkstemp from django.core import mail from django.core.files.uploadedfile import SimpleUploadedFile from django.core.urlresolvers import reverse +from django.template.base import TemplateDoesNotExist from django.test import TestCase, RequestFactory from django.test.utils import (override_settings, setup_test_template_loader, restore_template_loaders) @@ -113,6 +114,12 @@ class DebugViewTests(TestCase): finally: shutil.rmtree(template_path) + def test_no_template_source_loaders(self): + """ + Make sure if you don't specify a template, the debug view doesn't blow up. + """ + self.assertRaises(TemplateDoesNotExist, self.client.get, '/render_no_template/') + class ExceptionReporterTests(TestCase): rf = RequestFactory() diff --git a/tests/view_tests/urls.py b/tests/view_tests/urls.py index b0c06a1e56..ff9cc5630a 100644 --- a/tests/view_tests/urls.py +++ b/tests/view_tests/urls.py @@ -69,4 +69,5 @@ urlpatterns += patterns('view_tests.views', url(r'view_exception/(?P<n>\d+)/$', 'view_exception', name='view_exception'), url(r'template_exception/(?P<n>\d+)/$', 'template_exception', name='template_exception'), url(r'^raises_template_does_not_exist/(?P<path>.+)$', 'raises_template_does_not_exist', name='raises_template_does_not_exist'), + url(r'^render_no_template/$', 'render_no_template', name='render_no_template'), ) diff --git a/tests/view_tests/views.py b/tests/view_tests/views.py index 5fcf1703d4..2db6b09faa 100644 --- a/tests/view_tests/views.py +++ b/tests/view_tests/views.py @@ -123,6 +123,11 @@ def raises_template_does_not_exist(request, path='i_dont_exist.html'): except TemplateDoesNotExist: return technical_500_response(request, *sys.exc_info()) +def render_no_template(request): + # If we do not specify a template, we need to make sure the debug + # view doesn't blow up. + return render(request, [], {}) + def send_log(request, exc_info): logger = getLogger('django.request') # The default logging config has a logging filter to ensure admin emails are |
