summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/assertions.py10
-rw-r--r--lib/sqlalchemy/testing/plugin/plugin_base.py12
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py
index 05dcf230b..87e5ba0d2 100644
--- a/lib/sqlalchemy/testing/assertions.py
+++ b/lib/sqlalchemy/testing/assertions.py
@@ -285,13 +285,11 @@ def _assert_proper_exception_context(exception):
def assert_raises(except_cls, callable_, *args, **kw):
- _assert_raises(except_cls, callable_, args, kw, check_context=True)
+ return _assert_raises(except_cls, callable_, args, kw, check_context=True)
def assert_raises_context_ok(except_cls, callable_, *args, **kw):
- _assert_raises(
- except_cls, callable_, args, kw,
- )
+ return _assert_raises(except_cls, callable_, args, kw,)
def assert_raises_return(except_cls, callable_, *args, **kw):
@@ -299,7 +297,7 @@ def assert_raises_return(except_cls, callable_, *args, **kw):
def assert_raises_message(except_cls, msg, callable_, *args, **kwargs):
- _assert_raises(
+ return _assert_raises(
except_cls, callable_, args, kwargs, msg=msg, check_context=True
)
@@ -307,7 +305,7 @@ def assert_raises_message(except_cls, msg, callable_, *args, **kwargs):
def assert_raises_message_context_ok(
except_cls, msg, callable_, *args, **kwargs
):
- _assert_raises(except_cls, callable_, args, kwargs, msg=msg)
+ return _assert_raises(except_cls, callable_, args, kwargs, msg=msg)
def _assert_raises(
diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py
index 9b2f6911d..f7d0dd3ea 100644
--- a/lib/sqlalchemy/testing/plugin/plugin_base.py
+++ b/lib/sqlalchemy/testing/plugin/plugin_base.py
@@ -412,6 +412,17 @@ def _prep_testing_database(options, file_config):
if options.dropfirst:
for cfg in config.Config.all_configs():
e = cfg.db
+
+ # TODO: this has to be part of provision.py in postgresql
+ if against(cfg, "postgresql"):
+ with e.connect().execution_options(
+ isolation_level="AUTOCOMMIT"
+ ) as conn:
+ for xid in conn.execute(
+ "select gid from pg_prepared_xacts"
+ ).scalars():
+ conn.execute("ROLLBACK PREPARED '%s'" % xid)
+
inspector = inspect(e)
try:
view_names = inspector.get_view_names()
@@ -447,6 +458,7 @@ def _prep_testing_database(options, file_config):
if config.requirements.schemas.enabled_for_config(cfg):
util.drop_all_tables(e, inspector, schema=cfg.test_schema)
+ # TODO: this has to be part of provision.py in postgresql
if against(cfg, "postgresql"):
from sqlalchemy.dialects import postgresql