summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-04-15 18:31:30 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-04-15 18:31:30 +0000
commitbd303b10e2bf69169f07447c7272fc71ac931f10 (patch)
tree7d2b6b21fbf880062e0bfddd31c85382bf11ccf1 /test/sql
parent447c0750e1f739c4db1d0d20de182c297dc86e36 (diff)
parent8725d89abaf1a6ce870e71fbf1a4962dc4899204 (diff)
downloadsqlalchemy-bd303b10e2bf69169f07447c7272fc71ac931f10.tar.gz
Merge "Pass connection to TablesTest.insert_data()"
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_defaults.py7
-rw-r--r--test/sql/test_deprecations.py51
-rw-r--r--test/sql/test_resultset.py49
3 files changed, 49 insertions, 58 deletions
diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py
index 0a50a6356..fd5aec503 100644
--- a/test/sql/test_defaults.py
+++ b/test/sql/test_defaults.py
@@ -1446,11 +1446,12 @@ class InsertFromSelectTest(fixtures.TablesTest):
Table("data", metadata, Column("x", Integer), Column("y", Integer))
@classmethod
- def insert_data(cls):
+ def insert_data(cls, connection):
data = cls.tables.data
- with testing.db.connect() as conn:
- conn.execute(data.insert(), [{"x": 2, "y": 5}, {"x": 7, "y": 12}])
+ connection.execute(
+ data.insert(), [{"x": 2, "y": 5}, {"x": 7, "y": 12}]
+ )
@testing.provide_metadata
def test_insert_from_select_override_defaults(self, connection):
diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py
index 13d4cd154..43e906032 100644
--- a/test/sql/test_deprecations.py
+++ b/test/sql/test_deprecations.py
@@ -879,21 +879,19 @@ class KeyTargetingTest(fixtures.TablesTest):
)
@classmethod
- def insert_data(cls):
- with testing.db.connect() as conn:
- conn.execute(cls.tables.keyed1.insert(), dict(b="a1", q="c1"))
- conn.execute(cls.tables.keyed2.insert(), dict(a="a2", b="b2"))
- conn.execute(cls.tables.keyed3.insert(), dict(a="a3", d="d3"))
- conn.execute(cls.tables.keyed4.insert(), dict(b="b4", q="q4"))
- conn.execute(cls.tables.content.insert(), type="t1")
-
- if testing.requires.schemas.enabled:
- conn.execute(
- cls.tables[
- "%s.wschema" % testing.config.test_schema
- ].insert(),
- dict(b="a1", q="c1"),
- )
+ def insert_data(cls, connection):
+ conn = connection
+ conn.execute(cls.tables.keyed1.insert(), dict(b="a1", q="c1"))
+ conn.execute(cls.tables.keyed2.insert(), dict(a="a2", b="b2"))
+ conn.execute(cls.tables.keyed3.insert(), dict(a="a3", d="d3"))
+ conn.execute(cls.tables.keyed4.insert(), dict(b="b4", q="q4"))
+ conn.execute(cls.tables.content.insert(), type="t1")
+
+ if testing.requires.schemas.enabled:
+ conn.execute(
+ cls.tables["%s.wschema" % testing.config.test_schema].insert(),
+ dict(b="a1", q="c1"),
+ )
def test_column_label_overlap_fallback(self, connection):
content, bar = self.tables.content, self.tables.bar
@@ -1109,15 +1107,14 @@ class ResultProxyTest(fixtures.TablesTest):
)
@classmethod
- def insert_data(cls):
+ def insert_data(cls, connection):
users = cls.tables.users
- with testing.db.connect() as conn:
- conn.execute(
- users.insert(),
- dict(user_id=1, user_name="john"),
- dict(user_id=2, user_name="jack"),
- )
+ connection.execute(
+ users.insert(),
+ dict(user_id=1, user_name="john"),
+ dict(user_id=2, user_name="jack"),
+ )
def test_column_accessor_textual_select(self, connection):
users = self.tables.users
@@ -1481,12 +1478,10 @@ class PositionalTextTest(fixtures.TablesTest):
)
@classmethod
- def insert_data(cls):
- with testing.db.connect() as conn:
- conn.execute(
- cls.tables.text1.insert(),
- [dict(a="a1", b="b1", c="c1", d="d1")],
- )
+ def insert_data(cls, connection):
+ connection.execute(
+ cls.tables.text1.insert(), [dict(a="a1", b="b1", c="c1", d="d1")],
+ )
def test_anon_aliased_overlapping(self, connection):
text1 = self.tables.text1
diff --git a/test/sql/test_resultset.py b/test/sql/test_resultset.py
index f8d245228..470417dd3 100644
--- a/test/sql/test_resultset.py
+++ b/test/sql/test_resultset.py
@@ -1406,21 +1406,19 @@ class KeyTargetingTest(fixtures.TablesTest):
)
@classmethod
- def insert_data(cls):
- with testing.db.begin() as conn:
- conn.execute(cls.tables.keyed1.insert(), dict(b="a1", q="c1"))
- conn.execute(cls.tables.keyed2.insert(), dict(a="a2", b="b2"))
- conn.execute(cls.tables.keyed3.insert(), dict(a="a3", d="d3"))
- conn.execute(cls.tables.keyed4.insert(), dict(b="b4", q="q4"))
- conn.execute(cls.tables.content.insert(), dict(type="t1"))
-
- if testing.requires.schemas.enabled:
- conn.execute(
- cls.tables[
- "%s.wschema" % testing.config.test_schema
- ].insert(),
- dict(b="a1", q="c1"),
- )
+ def insert_data(cls, connection):
+ conn = connection
+ conn.execute(cls.tables.keyed1.insert(), dict(b="a1", q="c1"))
+ conn.execute(cls.tables.keyed2.insert(), dict(a="a2", b="b2"))
+ conn.execute(cls.tables.keyed3.insert(), dict(a="a3", d="d3"))
+ conn.execute(cls.tables.keyed4.insert(), dict(b="b4", q="q4"))
+ conn.execute(cls.tables.content.insert(), dict(type="t1"))
+
+ if testing.requires.schemas.enabled:
+ conn.execute(
+ cls.tables["%s.wschema" % testing.config.test_schema].insert(),
+ dict(b="a1", q="c1"),
+ )
@testing.requires.schemas
def test_keyed_accessor_wschema(self, connection):
@@ -1835,12 +1833,10 @@ class PositionalTextTest(fixtures.TablesTest):
)
@classmethod
- def insert_data(cls):
- with testing.db.connect() as conn:
- conn.execute(
- cls.tables.text1.insert(),
- [dict(a="a1", b="b1", c="c1", d="d1")],
- )
+ def insert_data(cls, connection):
+ connection.execute(
+ cls.tables.text1.insert(), [dict(a="a1", b="b1", c="c1", d="d1")],
+ )
def test_via_column(self, connection):
c1, c2, c3, c4 = column("q"), column("p"), column("r"), column("d")
@@ -2053,12 +2049,11 @@ class AlternateResultProxyTest(fixtures.TablesTest):
)
@classmethod
- def insert_data(cls):
- with cls.engine.connect() as conn:
- conn.execute(
- cls.tables.test.insert(),
- [{"x": i, "y": "t_%d" % i} for i in range(1, 12)],
- )
+ def insert_data(cls, connection):
+ connection.execute(
+ cls.tables.test.insert(),
+ [{"x": i, "y": "t_%d" % i} for i in range(1, 12)],
+ )
@contextmanager
def _proxy_fixture(self, cls):