summaryrefslogtreecommitdiff
path: root/test/sql/test_case_statement.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-08-17 17:24:27 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-09-16 12:31:05 -0400
commit7e864fc7b1b950760cbf02e6dcd5aa5aac267400 (patch)
tree2382b016c3eb82ae463719cc948f45ccd2a226a2 /test/sql/test_case_statement.py
parent8ebc8184392e20727748cd1405245e527f17e111 (diff)
downloadsqlalchemy-7e864fc7b1b950760cbf02e6dcd5aa5aac267400.tar.gz
Create a framework to allow all SQLALCHEMY_WARN_20 to pass
As the test suite has widespread use of many patterns that are deprecated, enable SQLALCHEMY_WARN_20 globally for the test suite but then break the warnings filter out into a whole list of all the individual warnings we are looking for. this way individual changesets can target a specific class of warning, as many of these warnings will indivdidually affect dozens of files and potentially hundreds of lines of code. Many warnings are also resolved here as this patch started out that way. From this point forward there should be changesets that target a subset of the warnings at a time. For expediency, updates some migration 2.0 docs for ORM as well. Change-Id: I98b8defdf7c37b818b3824d02f7668e3f5f31c94
Diffstat (limited to 'test/sql/test_case_statement.py')
-rw-r--r--test/sql/test_case_statement.py41
1 files changed, 23 insertions, 18 deletions
diff --git a/test/sql/test_case_statement.py b/test/sql/test_case_statement.py
index 74fe8876d..4bef1df7f 100644
--- a/test/sql/test_case_statement.py
+++ b/test/sql/test_case_statement.py
@@ -27,7 +27,7 @@ class CaseTest(fixtures.TestBase, AssertsCompiledSQL):
@classmethod
def setup_class(cls):
- metadata = MetaData(testing.db)
+ metadata = MetaData()
global info_table
info_table = Table(
"infos",
@@ -36,24 +36,29 @@ class CaseTest(fixtures.TestBase, AssertsCompiledSQL):
Column("info", String(30)),
)
- info_table.create()
-
- info_table.insert().execute(
- {"pk": 1, "info": "pk_1_data"},
- {"pk": 2, "info": "pk_2_data"},
- {"pk": 3, "info": "pk_3_data"},
- {"pk": 4, "info": "pk_4_data"},
- {"pk": 5, "info": "pk_5_data"},
- {"pk": 6, "info": "pk_6_data"},
- )
+ with testing.db.begin() as conn:
+ info_table.create(conn)
+
+ conn.execute(
+ info_table.insert(),
+ [
+ {"pk": 1, "info": "pk_1_data"},
+ {"pk": 2, "info": "pk_2_data"},
+ {"pk": 3, "info": "pk_3_data"},
+ {"pk": 4, "info": "pk_4_data"},
+ {"pk": 5, "info": "pk_5_data"},
+ {"pk": 6, "info": "pk_6_data"},
+ ],
+ )
@classmethod
def teardown_class(cls):
- info_table.drop()
+ with testing.db.begin() as conn:
+ info_table.drop(conn)
@testing.fails_on("firebird", "FIXME: unknown")
@testing.requires.subqueries
- def test_case(self):
+ def test_case(self, connection):
inner = select(
case(
(info_table.c.pk < 3, "lessthan3"),
@@ -63,7 +68,7 @@ class CaseTest(fixtures.TestBase, AssertsCompiledSQL):
info_table.c.info,
).select_from(info_table)
- inner_result = inner.execute().fetchall()
+ inner_result = connection.execute(inner).all()
# Outputs:
# lessthan3 1 pk_1_data
@@ -86,7 +91,7 @@ class CaseTest(fixtures.TestBase, AssertsCompiledSQL):
outer = select(inner.alias("q_inner"))
- outer_result = outer.execute().fetchall()
+ outer_result = connection.execute(outer).all()
assert outer_result == [
("lessthan3", 1, "pk_1_data"),
@@ -107,7 +112,7 @@ class CaseTest(fixtures.TestBase, AssertsCompiledSQL):
info_table.c.info,
).select_from(info_table)
- else_result = w_else.execute().fetchall()
+ else_result = connection.execute(w_else).all()
eq_(
else_result,
@@ -149,7 +154,7 @@ class CaseTest(fixtures.TestBase, AssertsCompiledSQL):
"CASE WHEN (test.col1 = :col1_1) THEN :param_1 ELSE :param_2 END",
)
- def test_text_doesnt_explode(self):
+ def test_text_doesnt_explode(self, connection):
for s in [
select(
@@ -169,7 +174,7 @@ class CaseTest(fixtures.TestBase, AssertsCompiledSQL):
).order_by(info_table.c.info),
]:
eq_(
- s.execute().fetchall(),
+ connection.execute(s).all(),
[("no",), ("no",), ("no",), ("yes",), ("no",), ("no",)],
)