Removed an inadvertent raise statement added in [8777] and added the printing of tracebacks for template tests that raise an unhandled exception.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10183 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Gary Wilson Jr 2009-03-29 23:33:01 +00:00
parent da3b38cdda
commit 4a9b1f7a36
1 changed files with 7 additions and 5 deletions

View File

@ -7,6 +7,7 @@ if __name__ == '__main__':
settings.configure() settings.configure()
import os import os
import traceback
import unittest import unittest
from datetime import datetime, timedelta from datetime import datetime, timedelta
@ -207,10 +208,11 @@ class Templates(unittest.TestCase):
try: try:
test_template = loader.get_template(name) test_template = loader.get_template(name)
output = self.render(test_template, vals) output = self.render(test_template, vals)
except Exception, e: except Exception:
if e.__class__ != result: exc_type, exc_value, exc_tb = sys.exc_info()
raise if exc_type != result:
failures.append("Template test (TEMPLATE_STRING_IF_INVALID='%s'): %s -- FAILED. Got %s, exception: %s" % (invalid_str, name, e.__class__, e)) tb = '\n'.join(traceback.format_exception(exc_type, exc_value, exc_tb))
failures.append("Template test (TEMPLATE_STRING_IF_INVALID='%s'): %s -- FAILED. Got %s, exception: %s\n%s" % (invalid_str, name, exc_type, exc_value, tb))
continue continue
if output != result: if output != result:
failures.append("Template test (TEMPLATE_STRING_IF_INVALID='%s'): %s -- FAILED. Expected %r, got %r" % (invalid_str, name, result, output)) failures.append("Template test (TEMPLATE_STRING_IF_INVALID='%s'): %s -- FAILED. Expected %r, got %r" % (invalid_str, name, result, output))
@ -227,7 +229,7 @@ class Templates(unittest.TestCase):
settings.TEMPLATE_DEBUG = old_td settings.TEMPLATE_DEBUG = old_td
settings.TEMPLATE_STRING_IF_INVALID = old_invalid settings.TEMPLATE_STRING_IF_INVALID = old_invalid
self.assertEqual(failures, [], '\n'.join(failures)) self.assertEqual(failures, [], ('-'*70 + '\n').join(failures))
def render(self, test_template, vals): def render(self, test_template, vals):
return test_template.render(template.Context(vals[1])) return test_template.render(template.Context(vals[1]))