summaryrefslogtreecommitdiff
path: root/tests/test_postgresql.py
diff options
context:
space:
mode:
authorCaselIT <cfederico87@gmail.com>2020-03-17 23:03:32 +0100
committerMike Bayer <mike_mp@zzzcomputing.com>2020-03-18 16:45:29 -0400
commit4f351a6ca8a6b5fe6718203226805f4e1a02a2db (patch)
tree311a185e5cda1a41dcbb02f4a81ed4ed9c82ad9c /tests/test_postgresql.py
parent0753306f9c96b23913f24041b3bf2f74d5dc74b1 (diff)
downloadalembic-4f351a6ca8a6b5fe6718203226805f4e1a02a2db.tar.gz
Support sqlalchemy 1.4 exec_driver_sql, text() for strings
Adjusted tests so that only connection-explicit execution is used, along with the use of text() for string invocation. Tests that are testing explicitly for deprecation warnings will bypass SQLAlchemy warnings. Added the RemovedIn20 warning as an error raise for these two specific deprecation cases. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I4f6b83366329aa95204522c9e99129021d1899fc
Diffstat (limited to 'tests/test_postgresql.py')
-rw-r--r--tests/test_postgresql.py42
1 files changed, 25 insertions, 17 deletions
diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py
index cfa265e..8c43510 100644
--- a/tests/test_postgresql.py
+++ b/tests/test_postgresql.py
@@ -307,17 +307,19 @@ class PGAutocommitBlockTest(TestBase):
self.conn = conn = config.db.connect()
with conn.begin():
- conn.execute("CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');")
+ conn.execute(
+ text("CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy')")
+ )
def tearDown(self):
with self.conn.begin():
- self.conn.execute("DROP TYPE mood")
+ self.conn.execute(text("DROP TYPE mood"))
def test_alter_enum(self):
context = MigrationContext.configure(connection=self.conn)
with context.begin_transaction(_per_migration=True):
with context.autocommit_block():
- context.execute("ALTER TYPE mood ADD VALUE 'soso'")
+ context.execute(text("ALTER TYPE mood ADD VALUE 'soso'"))
class PGOfflineEnumTest(TestBase):
@@ -430,25 +432,31 @@ class PostgresqlInlineLiteralTest(TestBase):
@classmethod
def setup_class(cls):
cls.bind = config.db
- cls.bind.execute(
+ with config.db.connect() as conn:
+ conn.execute(
+ text(
+ """
+ create table tab (
+ col varchar(50)
+ )
"""
- create table tab (
- col varchar(50)
+ )
)
- """
- )
- cls.bind.execute(
+ conn.execute(
+ text(
+ """
+ insert into tab (col) values
+ ('old data 1'),
+ ('old data 2.1'),
+ ('old data 3')
"""
- insert into tab (col) values
- ('old data 1'),
- ('old data 2.1'),
- ('old data 3')
- """
- )
+ )
+ )
@classmethod
def teardown_class(cls):
- cls.bind.execute("drop table tab")
+ with cls.bind.connect() as conn:
+ conn.execute(text("drop table tab"))
def setUp(self):
self.conn = self.bind.connect()
@@ -469,7 +477,7 @@ class PostgresqlInlineLiteralTest(TestBase):
)
eq_(
self.conn.execute(
- "select count(*) from tab where col='new data'"
+ text("select count(*) from tab where col='new data'")
).scalar(),
1,
)