Skip to content

Commit

Permalink
Removed an inadvertent raise statement added in [8777] and added the …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
gdub committed Mar 29, 2009
1 parent da3b38c commit 4a9b1f7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/regressiontests/templates/tests.py
Expand Up @@ -7,6 +7,7 @@
settings.configure()

import os
import traceback
import unittest
from datetime import datetime, timedelta

Expand Down Expand Up @@ -207,10 +208,11 @@ def test_template_loader(template_name, template_dirs=None):
try:
test_template = loader.get_template(name)
output = self.render(test_template, vals)
except Exception, e:
if e.__class__ != result:
raise
failures.append("Template test (TEMPLATE_STRING_IF_INVALID='%s'): %s -- FAILED. Got %s, exception: %s" % (invalid_str, name, e.__class__, e))
except Exception:
exc_type, exc_value, exc_tb = sys.exc_info()
if exc_type != result:
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
if output != result:
failures.append("Template test (TEMPLATE_STRING_IF_INVALID='%s'): %s -- FAILED. Expected %r, got %r" % (invalid_str, name, result, output))
Expand All @@ -227,7 +229,7 @@ def test_template_loader(template_name, template_dirs=None):
settings.TEMPLATE_DEBUG = old_td
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):
return test_template.render(template.Context(vals[1]))
Expand Down

0 comments on commit 4a9b1f7

Please sign in to comment.