]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Print useful traceback on error
authorScott Dugas <scott.dugas@foundationdb.com>
Thu, 23 Oct 2014 14:24:35 +0000 (10:24 -0400)
committerScott Dugas <scott.dugas@foundationdb.com>
Thu, 23 Oct 2014 14:24:35 +0000 (10:24 -0400)
_expect_failure was rethrowing the exception without keeping the
traceback, so it was really hard to find out what was actually wrong

lib/sqlalchemy/testing/exclusions.py

index 283d89e3688ef8fd1e4c49a7b530bef72cf34b10..5ce8bcd84c14e9712f0032773e73b72030d8b96f 100644 (file)
@@ -12,6 +12,7 @@ from ..util import decorator
 from . import config
 from .. import util
 import inspect
+import sys
 import contextlib
 
 
@@ -120,20 +121,21 @@ class compound(object):
 
         try:
             return_value = fn(*args, **kw)
-        except Exception as ex:
-            self._expect_failure(config, ex, name=fn.__name__)
+        except Exception:
+            exc_type, exc_value, exc_traceback = sys.exc_info()
+            self._expect_failure(config, exc_type, exc_value, exc_traceback, name=fn.__name__)
         else:
             self._expect_success(config, name=fn.__name__)
             return return_value
 
-    def _expect_failure(self, config, ex, name='block'):
+    def _expect_failure(self, config, exc_type, exc_value, exc_traceback, name='block'):
         for fail in self.fails:
             if fail(config):
                 print(("%s failed as expected (%s): %s " % (
                     name, fail._as_string(config), str(ex))))
                 break
         else:
-            raise ex
+            raise exc_type, exc_value, exc_traceback
 
     def _expect_success(self, config, name='block'):
         if not self.fails: