diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-04-14 15:30:28 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-04-15 11:12:59 -0400 |
| commit | 8725d89abaf1a6ce870e71fbf1a4962dc4899204 (patch) | |
| tree | d9a52a8e960a3ec087a5bda1cf03b498b945d162 /test/sql/test_deprecations.py | |
| parent | f39cf13680a0ee5b190d498d29ea31c76f546dfb (diff) | |
| download | sqlalchemy-8725d89abaf1a6ce870e71fbf1a4962dc4899204.tar.gz | |
Pass connection to TablesTest.insert_data()
towards the goal of reducing verbosity and repetition
in test fixtures as well as that we are moving to
connection only for execution, move the insert_data()
classmethod to accept a connection and adjust all
fixtures to use it.
Change-Id: I3bf534acca0d5f4cda1d4da8ae91f1155b829b09
Diffstat (limited to 'test/sql/test_deprecations.py')
| -rw-r--r-- | test/sql/test_deprecations.py | 51 |
1 files changed, 23 insertions, 28 deletions
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 |
