From 25434e9209af9ee2c05b651bc4fe197541c0bd60 Mon Sep 17 00:00:00 2001 From: Scott Dugas Date: Wed, 22 Oct 2014 15:09:05 -0400 Subject: Support additional args/kwargs on cursor method fdbsql has an optional nested kwarg, which is supported in the actual code, but not in the testing proxy --- lib/sqlalchemy/testing/engines.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/testing') diff --git a/lib/sqlalchemy/testing/engines.py b/lib/sqlalchemy/testing/engines.py index 67c13231e..75bcc58e1 100644 --- a/lib/sqlalchemy/testing/engines.py +++ b/lib/sqlalchemy/testing/engines.py @@ -284,10 +284,10 @@ class DBAPIProxyCursor(object): """ - def __init__(self, engine, conn): + def __init__(self, engine, conn, *args, **kwargs): self.engine = engine self.connection = conn - self.cursor = conn.cursor() + self.cursor = conn.cursor(*args, **kwargs) def execute(self, stmt, parameters=None, **kw): if parameters: @@ -315,8 +315,10 @@ class DBAPIProxyConnection(object): self.engine = engine self.cursor_cls = cursor_cls - def cursor(self): - return self.cursor_cls(self.engine, self.conn) + def cursor(self, *args, **kwargs): + print "DPA", args + print "DPK", kwargs + return self.cursor_cls(self.engine, self.conn, *args, **kwargs) def close(self): self.conn.close() -- cgit v1.2.1 From 9c0eb840788ed5971f0876958cfb9866c7af918d Mon Sep 17 00:00:00 2001 From: Scott Dugas Date: Thu, 23 Oct 2014 10:24:35 -0400 Subject: 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(-) (limited to 'lib/sqlalchemy/testing') diff --git a/lib/sqlalchemy/testing/exclusions.py b/lib/sqlalchemy/testing/exclusions.py index 283d89e36..5ce8bcd84 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: -- cgit v1.2.1 From 2ce9333a24a1f894de4bf028f51eb1de28c10a3d Mon Sep 17 00:00:00 2001 From: Scott Dugas Date: Thu, 23 Oct 2014 13:01:23 -0400 Subject: Forgot to update usage of ex to exc_value --- lib/sqlalchemy/testing/exclusions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/sqlalchemy/testing') diff --git a/lib/sqlalchemy/testing/exclusions.py b/lib/sqlalchemy/testing/exclusions.py index 5ce8bcd84..c9f81c8b9 100644 --- a/lib/sqlalchemy/testing/exclusions.py +++ b/lib/sqlalchemy/testing/exclusions.py @@ -132,7 +132,7 @@ class compound(object): for fail in self.fails: if fail(config): print(("%s failed as expected (%s): %s " % ( - name, fail._as_string(config), str(ex)))) + name, fail._as_string(config), str(exc_value)))) break else: raise exc_type, exc_value, exc_traceback -- cgit v1.2.1 From ebb9d57cb385f49becbf54c6f78647715ddd1c29 Mon Sep 17 00:00:00 2001 From: Scott Dugas Date: Thu, 30 Oct 2014 16:40:36 -0400 Subject: Removed accidental print statements --- lib/sqlalchemy/testing/engines.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/sqlalchemy/testing') diff --git a/lib/sqlalchemy/testing/engines.py b/lib/sqlalchemy/testing/engines.py index 75bcc58e1..3a3f5be10 100644 --- a/lib/sqlalchemy/testing/engines.py +++ b/lib/sqlalchemy/testing/engines.py @@ -316,8 +316,6 @@ class DBAPIProxyConnection(object): self.cursor_cls = cursor_cls def cursor(self, *args, **kwargs): - print "DPA", args - print "DPK", kwargs return self.cursor_cls(self.engine, self.conn, *args, **kwargs) def close(self): -- cgit v1.2.1 From 8d154f84f1a552c290a1ccd802f20940c8cab066 Mon Sep 17 00:00:00 2001 From: Scott Dugas Date: Mon, 3 Nov 2014 15:24:31 -0500 Subject: It now calls raise_from_cause master was updated to call util.raise_from_cause which is better than what I had --- lib/sqlalchemy/testing/exclusions.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lib/sqlalchemy/testing') diff --git a/lib/sqlalchemy/testing/exclusions.py b/lib/sqlalchemy/testing/exclusions.py index e3d91300d..f94724608 100644 --- a/lib/sqlalchemy/testing/exclusions.py +++ b/lib/sqlalchemy/testing/exclusions.py @@ -12,7 +12,6 @@ from ..util import decorator from . import config from .. import util import inspect -import sys import contextlib @@ -121,18 +120,17 @@ class compound(object): try: return_value = fn(*args, **kw) - except Exception: - exc_type, exc_value, exc_traceback = sys.exc_info() - self._expect_failure(config, exc_type, exc_value, exc_traceback, name=fn.__name__) + except Exception as ex: + self._expect_failure(config, ex, name=fn.__name__) else: self._expect_success(config, name=fn.__name__) return return_value - def _expect_failure(self, config, exc_type, exc_value, exc_traceback, name='block'): + def _expect_failure(self, config, ex, name='block'): for fail in self.fails: if fail(config): print(("%s failed as expected (%s): %s " % ( - name, fail._as_string(config), str(exc_value)))) + name, fail._as_string(config), str(ex)))) break else: util.raise_from_cause(ex) -- cgit v1.2.1