summaryrefslogtreecommitdiff
path: root/test/dialect/mysql/test_query.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-11-15 16:58:50 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-12-11 13:26:05 -0500
commitba5cbf9366e9b2c5ed8e27e91815d7a2c3b63e41 (patch)
tree038f2263d581d5e49d74731af68febc4bf64eb19 /test/dialect/mysql/test_query.py
parent87d58b6d8188ccff808b3207d5f9398bb9adf9b9 (diff)
downloadsqlalchemy-ba5cbf9366e9b2c5ed8e27e91815d7a2c3b63e41.tar.gz
correct for "autocommit" deprecation warning
Ensure no autocommit warnings occur internally or within tests. Also includes fixes for SQL Server full text tests which apparently have not been working at all for a long time, as it used long removed APIs. CI has not had fulltext running for some years and is now installed. Change-Id: Id806e1856c9da9f0a9eac88cebc7a94ecc95eb96
Diffstat (limited to 'test/dialect/mysql/test_query.py')
-rw-r--r--test/dialect/mysql/test_query.py108
1 files changed, 48 insertions, 60 deletions
diff --git a/test/dialect/mysql/test_query.py b/test/dialect/mysql/test_query.py
index f9d9caf16..f56cd98aa 100644
--- a/test/dialect/mysql/test_query.py
+++ b/test/dialect/mysql/test_query.py
@@ -9,7 +9,6 @@ from sqlalchemy import Column
from sqlalchemy import false
from sqlalchemy import ForeignKey
from sqlalchemy import Integer
-from sqlalchemy import MetaData
from sqlalchemy import or_
from sqlalchemy import select
from sqlalchemy import String
@@ -44,16 +43,13 @@ class IdiosyncrasyTest(fixtures.TestBase):
)
-class MatchTest(fixtures.TestBase):
+class MatchTest(fixtures.TablesTest):
__only_on__ = "mysql", "mariadb"
__backend__ = True
@classmethod
- def setup_class(cls):
- global metadata, cattable, matchtable
- metadata = MetaData(testing.db)
-
- cattable = Table(
+ def define_tables(cls, metadata):
+ Table(
"cattable",
metadata,
Column("id", Integer, primary_key=True),
@@ -61,7 +57,7 @@ class MatchTest(fixtures.TestBase):
mysql_engine="MyISAM",
mariadb_engine="MyISAM",
)
- matchtable = Table(
+ Table(
"matchtable",
metadata,
Column("id", Integer, primary_key=True),
@@ -70,15 +66,20 @@ class MatchTest(fixtures.TestBase):
mysql_engine="MyISAM",
mariadb_engine="MyISAM",
)
- metadata.create_all()
- cattable.insert().execute(
+ @classmethod
+ def insert_data(cls, connection):
+ cattable, matchtable = cls.tables("cattable", "matchtable")
+
+ connection.execute(
+ cattable.insert(),
[
{"id": 1, "description": "Python"},
{"id": 2, "description": "Ruby"},
- ]
+ ],
)
- matchtable.insert().execute(
+ connection.execute(
+ matchtable.insert(),
[
{
"id": 1,
@@ -97,43 +98,36 @@ class MatchTest(fixtures.TestBase):
"category_id": 1,
},
{"id": 5, "title": "Python in a Nutshell", "category_id": 1},
- ]
+ ],
)
- @classmethod
- def teardown_class(cls):
- metadata.drop_all()
-
- def test_simple_match(self):
- results = (
+ def test_simple_match(self, connection):
+ matchtable = self.tables.matchtable
+ results = connection.execute(
matchtable.select()
.where(matchtable.c.title.match("python"))
.order_by(matchtable.c.id)
- .execute()
- .fetchall()
- )
+ ).fetchall()
eq_([2, 5], [r.id for r in results])
- def test_not_match(self):
- results = (
+ def test_not_match(self, connection):
+ matchtable = self.tables.matchtable
+ results = connection.execute(
matchtable.select()
.where(~matchtable.c.title.match("python"))
.order_by(matchtable.c.id)
- .execute()
- .fetchall()
)
eq_([1, 3, 4], [r.id for r in results])
- def test_simple_match_with_apostrophe(self):
- results = (
- matchtable.select()
- .where(matchtable.c.title.match("Matz's"))
- .execute()
- .fetchall()
- )
+ def test_simple_match_with_apostrophe(self, connection):
+ matchtable = self.tables.matchtable
+ results = connection.execute(
+ matchtable.select().where(matchtable.c.title.match("Matz's"))
+ ).fetchall()
eq_([3], [r.id for r in results])
def test_return_value(self, connection):
+ matchtable = self.tables.matchtable
# test [ticket:3263]
result = connection.execute(
select(
@@ -155,8 +149,9 @@ class MatchTest(fixtures.TestBase):
],
)
- def test_or_match(self):
- results1 = (
+ def test_or_match(self, connection):
+ matchtable = self.tables.matchtable
+ results1 = connection.execute(
matchtable.select()
.where(
or_(
@@ -165,42 +160,37 @@ class MatchTest(fixtures.TestBase):
)
)
.order_by(matchtable.c.id)
- .execute()
- .fetchall()
- )
+ ).fetchall()
eq_([1, 3, 5], [r.id for r in results1])
- results2 = (
+ results2 = connection.execute(
matchtable.select()
.where(matchtable.c.title.match("nutshell ruby"))
.order_by(matchtable.c.id)
- .execute()
- .fetchall()
- )
+ ).fetchall()
eq_([1, 3, 5], [r.id for r in results2])
- def test_and_match(self):
- results1 = (
- matchtable.select()
- .where(
+ def test_and_match(self, connection):
+ matchtable = self.tables.matchtable
+ results1 = connection.execute(
+ matchtable.select().where(
and_(
matchtable.c.title.match("python"),
matchtable.c.title.match("nutshell"),
)
)
- .execute()
- .fetchall()
- )
+ ).fetchall()
eq_([5], [r.id for r in results1])
- results2 = (
- matchtable.select()
- .where(matchtable.c.title.match("+python +nutshell"))
- .execute()
- .fetchall()
- )
+ results2 = connection.execute(
+ matchtable.select().where(
+ matchtable.c.title.match("+python +nutshell")
+ )
+ ).fetchall()
eq_([5], [r.id for r in results2])
- def test_match_across_joins(self):
- results = (
+ def test_match_across_joins(self, connection):
+ matchtable = self.tables.matchtable
+ cattable = self.tables.cattable
+ results = connection.execute(
matchtable.select()
.where(
and_(
@@ -212,9 +202,7 @@ class MatchTest(fixtures.TestBase):
)
)
.order_by(matchtable.c.id)
- .execute()
- .fetchall()
- )
+ ).fetchall()
eq_([1, 3, 5], [r.id for r in results])