summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/fixtures.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-02-19 22:59:46 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-02-19 22:59:46 +0000
commit8c9537d37292459d348214fb8befa85d9cb64059 (patch)
tree74d9872d2a324058f0e94bf5046fc042225ffe12 /lib/sqlalchemy/testing/fixtures.py
parent5ad9e9fbb25decff09104b03904cfe00a2b18916 (diff)
parent60f627cbd0d769e65353e720548efac9d8ab95d9 (diff)
downloadsqlalchemy-8c9537d37292459d348214fb8befa85d9cb64059.tar.gz
Merge "Replace engine.execute w/ context manager (step1)"
Diffstat (limited to 'lib/sqlalchemy/testing/fixtures.py')
-rw-r--r--lib/sqlalchemy/testing/fixtures.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py
index 62bf9fc1f..bae0cee89 100644
--- a/lib/sqlalchemy/testing/fixtures.py
+++ b/lib/sqlalchemy/testing/fixtures.py
@@ -56,6 +56,32 @@ class TestBase(object):
if hasattr(self, "tearDown"):
self.tearDown()
+ @config.fixture()
+ def connection(self):
+ conn = config.db.connect()
+ trans = conn.begin()
+ try:
+ yield conn
+ finally:
+ trans.rollback()
+ conn.close()
+
+ # propose a replacement for @testing.provide_metadata.
+ # the problem with this is that TablesTest below has a ".metadata"
+ # attribute already which is accessed directly as part of the
+ # @testing.provide_metadata pattern. Might need to call this _metadata
+ # for it to be useful.
+ # @config.fixture()
+ # def metadata(self):
+ # """Provide bound MetaData for a single test, dropping afterwards."""
+ #
+ # from . import engines
+ # metadata = schema.MetaData(config.db)
+ # try:
+ # yield metadata
+ # finally:
+ # engines.drop_all_tables(metadata, config.db)
+
class TablesTest(TestBase):