Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #4457 -- Corrected the handling of exceptions in the test clien…

…t when the 500.html template is not available. Thanks to Chris Wager <cw264701@ohiou.edu> for his help in tracking down this problem.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6023 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 258af283fc398ff99c2de9386b494eb1910e2d74 1 parent 44e6209
Russell Keith-Magee freakboy3742 authored
Showing with 16 additions and 5 deletions.
  1. +16 −5 django/test/client.py
21 django/test/client.py
View
@@ -11,6 +11,7 @@
from django.core.signals import got_request_exception
from django.dispatch import dispatcher
from django.http import SimpleCookie, HttpRequest
+from django.template import TemplateDoesNotExist
from django.test import signals
from django.utils.functional import curry
from django.utils.encoding import smart_str
@@ -165,7 +166,21 @@ def request(self, **request):
# Capture exceptions created by the handler
dispatcher.connect(self.store_exc_info, signal=got_request_exception)
- response = self.handler(environ)
+ try:
+ response = self.handler(environ)
+ except TemplateDoesNotExist, e:
+ # If the view raises an exception, Django will attempt to show
+ # the 500.html template. If that template is not available,
+ # we should ignore the error in favor of re-raising the
+ # underlying exception that caused the 500 error. Any other
+ # template found to be missing during view error handling
+ # should be reported as-is.
+ if e.args != ('500.html',):
+ raise
+
+ # Look for a signalled exception and reraise it
+ if self.exc_info:
+ raise self.exc_info[1], None, self.exc_info[2]
# Add any rendered template detail to the response
# If there was only one template rendered (the most likely case),
@@ -179,10 +194,6 @@ def request(self, **request):
else:
setattr(response, detail, None)
- # Look for a signalled exception and reraise it
- if self.exc_info:
- raise self.exc_info[1], None, self.exc_info[2]
-
# Update persistent cookie data
if response.cookies:
self.cookies.update(response.cookies)
Please sign in to comment.
Something went wrong with that request. Please try again.