Django

Code

Changeset 6023

Show
Ignore:
Timestamp:
08/28/07 08:03:22 (1 year ago)
Author:
russellm
Message:

Fixed #4457 -- Corrected the handling of exceptions in the test client when the 500.html template is not available. Thanks to Chris Wager <cw264701@ohiou.edu> for his help in tracking down this problem.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/test/client.py

    r5916 r6023  
    1212from django.dispatch import dispatcher 
    1313from django.http import SimpleCookie, HttpRequest 
     14from django.template import TemplateDoesNotExist 
    1415from django.test import signals 
    1516from django.utils.functional import curry 
     
    166167        dispatcher.connect(self.store_exc_info, signal=got_request_exception) 
    167168 
    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] 
    169184 
    170185        # Add any rendered template detail to the response 
     
    180195                setattr(response, detail, None) 
    181196 
    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  
    186197        # Update persistent cookie data 
    187198        if response.cookies: