summaryrefslogtreecommitdiff
path: root/test/ext
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/ext
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/ext')
-rw-r--r--test/ext/test_associationproxy.py56
-rw-r--r--test/ext/test_horizontal_shard.py15
2 files changed, 40 insertions, 31 deletions
diff --git a/test/ext/test_associationproxy.py b/test/ext/test_associationproxy.py
index 3cb29c67d..df27c8d27 100644
--- a/test/ext/test_associationproxy.py
+++ b/test/ext/test_associationproxy.py
@@ -1329,10 +1329,13 @@ class KVChild(object):
self.value = value
-class ReconstitutionTest(fixtures.TestBase):
- def setup(self):
- metadata = MetaData(testing.db)
- parents = Table(
+class ReconstitutionTest(fixtures.MappedTest):
+ run_setup_mappers = "each"
+ run_setup_classes = "each"
+
+ @classmethod
+ def define_tables(cls, metadata):
+ Table(
"parents",
metadata,
Column(
@@ -1340,7 +1343,7 @@ class ReconstitutionTest(fixtures.TestBase):
),
Column("name", String(30)),
)
- children = Table(
+ Table(
"children",
metadata,
Column(
@@ -1349,22 +1352,23 @@ class ReconstitutionTest(fixtures.TestBase):
Column("parent_id", Integer, ForeignKey("parents.id")),
Column("name", String(30)),
)
- metadata.create_all()
- parents.insert().execute(name="p1")
- self.metadata = metadata
- self.parents = parents
- self.children = children
- Parent.kids = association_proxy("children", "name")
- def teardown(self):
- self.metadata.drop_all()
- clear_mappers()
+ @classmethod
+ def insert_data(cls, connection):
+ parents = cls.tables.parents
+ connection.execute(parents.insert(), dict(name="p1"))
+
+ @classmethod
+ def setup_classes(cls):
+ Parent.kids = association_proxy("children", "name")
def test_weak_identity_map(self):
mapper(
- Parent, self.parents, properties=dict(children=relationship(Child))
+ Parent,
+ self.tables.parents,
+ properties=dict(children=relationship(Child)),
)
- mapper(Child, self.children)
+ mapper(Child, self.tables.children)
session = create_session()
def add_child(parent_name, child_name):
@@ -1380,9 +1384,11 @@ class ReconstitutionTest(fixtures.TestBase):
def test_copy(self):
mapper(
- Parent, self.parents, properties=dict(children=relationship(Child))
+ Parent,
+ self.tables.parents,
+ properties=dict(children=relationship(Child)),
)
- mapper(Child, self.children)
+ mapper(Child, self.tables.children)
p = Parent("p1")
p.kids.extend(["c1", "c2"])
p_copy = copy.copy(p)
@@ -1392,9 +1398,11 @@ class ReconstitutionTest(fixtures.TestBase):
def test_pickle_list(self):
mapper(
- Parent, self.parents, properties=dict(children=relationship(Child))
+ Parent,
+ self.tables.parents,
+ properties=dict(children=relationship(Child)),
)
- mapper(Child, self.children)
+ mapper(Child, self.tables.children)
p = Parent("p1")
p.kids.extend(["c1", "c2"])
r1 = pickle.loads(pickle.dumps(p))
@@ -1407,12 +1415,12 @@ class ReconstitutionTest(fixtures.TestBase):
def test_pickle_set(self):
mapper(
Parent,
- self.parents,
+ self.tables.parents,
properties=dict(
children=relationship(Child, collection_class=set)
),
)
- mapper(Child, self.children)
+ mapper(Child, self.tables.children)
p = Parent("p1")
p.kids.update(["c1", "c2"])
r1 = pickle.loads(pickle.dumps(p))
@@ -1425,7 +1433,7 @@ class ReconstitutionTest(fixtures.TestBase):
def test_pickle_dict(self):
mapper(
Parent,
- self.parents,
+ self.tables.parents,
properties=dict(
children=relationship(
KVChild,
@@ -1435,7 +1443,7 @@ class ReconstitutionTest(fixtures.TestBase):
)
),
)
- mapper(KVChild, self.children)
+ mapper(KVChild, self.tables.children)
p = Parent("p1")
p.kids.update({"c1": "v1", "c2": "v2"})
assert p.kids == {"c1": "c1", "c2": "c2"}
diff --git a/test/ext/test_horizontal_shard.py b/test/ext/test_horizontal_shard.py
index a8c17d7ac..e46c65ff0 100644
--- a/test/ext/test_horizontal_shard.py
+++ b/test/ext/test_horizontal_shard.py
@@ -53,10 +53,10 @@ class ShardTest(object):
def id_generator(ctx):
# in reality, might want to use a separate transaction for this.
- c = db1.connect()
- nextid = c.execute(ids.select().with_for_update()).scalar()
- c.execute(ids.update(values={ids.c.nextid: ids.c.nextid + 1}))
- return nextid
+ with db1.begin() as c:
+ nextid = c.execute(ids.select().with_for_update()).scalar()
+ c.execute(ids.update(values={ids.c.nextid: ids.c.nextid + 1}))
+ return nextid
weather_locations = Table(
"weather_locations",
@@ -80,7 +80,8 @@ class ShardTest(object):
for db in (db1, db2, db3, db4):
meta.create_all(db)
- db1.execute(ids.insert(), nextid=1)
+ with db1.begin() as conn:
+ conn.execute(ids.insert(), dict(nextid=1))
self.setup_session()
self.setup_mappers()
@@ -762,7 +763,7 @@ class MultipleDialectShardTest(ShardTest, fixtures.TestBase):
)
e2 = testing_engine()
- with e2.connect() as conn:
+ with e2.begin() as conn:
for i in [2, 4]:
conn.exec_driver_sql(
"CREATE SCHEMA IF NOT EXISTS shard%s" % (i,)
@@ -784,7 +785,7 @@ class MultipleDialectShardTest(ShardTest, fixtures.TestBase):
for i in [1, 3]:
os.remove("shard%d_%s.db" % (i, provision.FOLLOWER_IDENT))
- with self.postgresql_engine.connect() as conn:
+ with self.postgresql_engine.begin() as conn:
self.metadata.drop_all(conn)
for i in [2, 4]:
conn.exec_driver_sql("DROP SCHEMA shard%s CASCADE" % (i,))