Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored August 28, 2007

Showing 1 changed file with 16 additions and 5 deletions. Show diff stats Hide diff stats

  1. 21  django/test/client.py
21  django/test/client.py
@@ -11,6 +11,7 @@
11 11
 from django.core.signals import got_request_exception
12 12
 from django.dispatch import dispatcher
13 13
 from django.http import SimpleCookie, HttpRequest
  14
+from django.template import TemplateDoesNotExist
14 15
 from django.test import signals
15 16
 from django.utils.functional import curry
16 17
 from django.utils.encoding import smart_str
@@ -165,7 +166,21 @@ def request(self, **request):
165 166
         # Capture exceptions created by the handler
166 167
         dispatcher.connect(self.store_exc_info, signal=got_request_exception)
167 168
 
168  
-        response = self.handler(environ)
  169
+        try:
  170
+            response = self.handler(environ)
  171
+        except TemplateDoesNotExist, e:
  172
+            # If the view raises an exception, Django will attempt to show
  173
+            # the 500.html template. If that template is not available,
  174
+            # we should ignore the error in favor of re-raising the
  175
+            # underlying exception that caused the 500 error. Any other
  176
+            # template found to be missing during view error handling
  177
+            # should be reported as-is.
  178
+            if e.args != ('500.html',):
  179
+                raise
  180
+
  181
+        # Look for a signalled exception and reraise it
  182
+        if self.exc_info:
  183
+            raise self.exc_info[1], None, self.exc_info[2]
169 184
 
170 185
         # Add any rendered template detail to the response
171 186
         # If there was only one template rendered (the most likely case),
@@ -179,10 +194,6 @@ def request(self, **request):
179 194
             else:
180 195
                 setattr(response, detail, None)
181 196
 
182  
-        # Look for a signalled exception and reraise it
183  
-        if self.exc_info:
184  
-            raise self.exc_info[1], None, self.exc_info[2]
185  
-
186 197
         # Update persistent cookie data
187 198
         if response.cookies:
188 199
             self.cookies.update(response.cookies)

0 notes on commit 258af28

Please sign in to comment.
Something went wrong with that request. Please try again.