From 9c0eb840788ed5971f0876958cfb9866c7af918d Mon Sep 17 00:00:00 2001 From: Scott Dugas Date: Thu, 23 Oct 2014 10:24:35 -0400 Subject: [PATCH] Print useful traceback on error _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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/sqlalchemy/testing/exclusions.py b/lib/sqlalchemy/testing/exclusions.py index 283d89e368..5ce8bcd84c 100644 --- a/lib/sqlalchemy/testing/exclusions.py +++ b/lib/sqlalchemy/testing/exclusions.py @@ -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: -- 2.47.3