Author: gwilson
Date: 2009-03-29 18:40:04 -0500 (Sun, 29 Mar 2009)
New Revision: 10185

Modified:
   django/branches/releases/1.0.X/tests/regressiontests/templates/tests.py
Log:
[1.0.X]: Removed an inadvertent raise statement added in [8777] and added the 
printing of tracebacks for template tests that raise an unhandled exception.

Backport of r10183 from trunk.


Modified: 
django/branches/releases/1.0.X/tests/regressiontests/templates/tests.py
===================================================================
--- django/branches/releases/1.0.X/tests/regressiontests/templates/tests.py     
2009-03-29 23:35:09 UTC (rev 10184)
+++ django/branches/releases/1.0.X/tests/regressiontests/templates/tests.py     
2009-03-29 23:40:04 UTC (rev 10185)
@@ -7,6 +7,7 @@
     settings.configure()
 
 import os
+import traceback
 import unittest
 from datetime import datetime, timedelta
 
@@ -203,10 +204,11 @@
                 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))
@@ -223,7 +225,7 @@
         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]))


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to