diff options
author | Iacopo Spalletti <i.spalletti@nephila.it> | 2015-11-07 17:24:07 +0100 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2016-01-14 07:05:38 -0500 |
commit | 21bf685f5e660a187fcac31e84d5cd89758aeb74 (patch) | |
tree | 04ff69e8a2f9ebeee8b1097fd2af8aceebd535f7 /tests/view_tests | |
parent | 8d5d472c6ddf42bacff72e533e7cfa08593fcd1a (diff) | |
download | django-21bf685f5e660a187fcac31e84d5cd89758aeb74.tar.gz |
Fixed #25697 -- Made default error views error when passed a nonexistent template_name.
Diffstat (limited to 'tests/view_tests')
-rw-r--r-- | tests/view_tests/tests/test_defaults.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/view_tests/tests/test_defaults.py b/tests/view_tests/tests/test_defaults.py index a729276887..1ef8bbaf74 100644 --- a/tests/view_tests/tests/test_defaults.py +++ b/tests/view_tests/tests/test_defaults.py @@ -4,8 +4,13 @@ import datetime from django.contrib.auth.models import User from django.contrib.sites.models import Site -from django.test import TestCase +from django.http import Http404 +from django.template import TemplateDoesNotExist +from django.test import RequestFactory, TestCase from django.test.utils import override_settings +from django.views.defaults import ( + bad_request, page_not_found, permission_denied, server_error, +) from ..models import Article, Author, UrlArticle @@ -123,3 +128,23 @@ class DefaultsTests(TestCase): response = self.client.get('/server_error/') self.assertEqual(response['Content-Type'], 'text/html') + + def test_custom_templates_wrong(self): + """ + Default error views should raise TemplateDoesNotExist when passed a + template that doesn't exist. + """ + rf = RequestFactory() + request = rf.get('/') + + with self.assertRaises(TemplateDoesNotExist): + bad_request(request, Exception(), template_name='nonexistent') + + with self.assertRaises(TemplateDoesNotExist): + permission_denied(request, Exception(), template_name='nonexistent') + + with self.assertRaises(TemplateDoesNotExist): + page_not_found(request, Http404(), template_name='nonexistent') + + with self.assertRaises(TemplateDoesNotExist): + server_error(request, template_name='nonexistent') |