summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2021-06-26 10:17:57 -0600
committerGord Thompson <gord@gordthompson.com>2021-06-26 16:10:57 -0600
commit0e91400f1b35520af838131718fc170235799a5b (patch)
treea65de9f4124e0da40b868abcb1a9300bb5d278b0
parent77e58046dc9222a4a869443cf30bc9ff39312f9d (diff)
downloadsqlalchemy-0e91400f1b35520af838131718fc170235799a5b.tar.gz
Modernize tests - Connection.connect
Change-Id: I61639dc2d7e7bcae6c53e2a15680b11fce3efa5d
-rw-r--r--lib/sqlalchemy/testing/warnings.py1
-rw-r--r--test/engine/test_deprecations.py30
-rw-r--r--test/engine/test_reconnect.py17
-rw-r--r--test/orm/test_transaction.py5
4 files changed, 40 insertions, 13 deletions
diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py
index fd7748050..30f50a44f 100644
--- a/lib/sqlalchemy/testing/warnings.py
+++ b/lib/sqlalchemy/testing/warnings.py
@@ -69,7 +69,6 @@ def setup_filters():
# Core execution
#
r"The (?:Executable|Engine)\.(?:execute|scalar)\(\) method",
- r"The Connection.connect\(\) method is considered legacy",
# r".*DefaultGenerator.execute\(\)",
#
#
diff --git a/test/engine/test_deprecations.py b/test/engine/test_deprecations.py
index fce9946dd..795cc5a4c 100644
--- a/test/engine/test_deprecations.py
+++ b/test/engine/test_deprecations.py
@@ -518,7 +518,10 @@ class TransactionTest(ResetFixture, fixtures.TablesTest):
connection = local_connection
users = self.tables.users
connection.begin()
- branched = connection.connect()
+ with testing.expect_deprecated_20(
+ r"The Connection.connect\(\) method is considered legacy"
+ ):
+ branched = connection.connect()
assert branched.in_transaction()
branched.execute(users.insert(), dict(user_id=1, user_name="user1"))
with testing.expect_deprecated_20(
@@ -872,7 +875,10 @@ class TransactionTest(ResetFixture, fixtures.TablesTest):
def test_branch_autorollback(self, local_connection):
connection = local_connection
users = self.tables.users
- branched = connection.connect()
+ with testing.expect_deprecated_20(
+ r"The Connection.connect\(\) method is considered legacy"
+ ):
+ branched = connection.connect()
with testing.expect_deprecated_20(
"The current statement is being autocommitted using "
"implicit autocommit"
@@ -898,7 +904,10 @@ class TransactionTest(ResetFixture, fixtures.TablesTest):
def test_branch_orig_rollback(self, local_connection):
connection = local_connection
users = self.tables.users
- branched = connection.connect()
+ with testing.expect_deprecated_20(
+ r"The Connection.connect\(\) method is considered legacy"
+ ):
+ branched = connection.connect()
with testing.expect_deprecated_20(
"The current statement is being autocommitted using "
"implicit autocommit"
@@ -919,7 +928,10 @@ class TransactionTest(ResetFixture, fixtures.TablesTest):
def test_branch_autocommit(self, local_connection):
users = self.tables.users
with testing.db.connect() as connection:
- branched = connection.connect()
+ with testing.expect_deprecated_20(
+ r"The Connection.connect\(\) method is considered legacy"
+ ):
+ branched = connection.connect()
with testing.expect_deprecated_20(
"The current statement is being autocommitted using "
"implicit autocommit"
@@ -940,7 +952,10 @@ class TransactionTest(ResetFixture, fixtures.TablesTest):
connection = local_connection
users = self.tables.users
trans = connection.begin()
- branched = connection.connect()
+ with testing.expect_deprecated_20(
+ r"The Connection.connect\(\) method is considered legacy"
+ ):
+ branched = connection.connect()
assert branched.in_transaction()
branched.execute(users.insert(), dict(user_id=1, user_name="user1"))
nested = branched.begin_nested()
@@ -957,7 +972,10 @@ class TransactionTest(ResetFixture, fixtures.TablesTest):
def test_branch_twophase_rollback(self, local_connection):
connection = local_connection
users = self.tables.users
- branched = connection.connect()
+ with testing.expect_deprecated_20(
+ r"The Connection.connect\(\) method is considered legacy"
+ ):
+ branched = connection.connect()
assert not branched.in_transaction()
with testing.expect_deprecated_20(
r"The current statement is being autocommitted using "
diff --git a/test/engine/test_reconnect.py b/test/engine/test_reconnect.py
index 70c4c5190..538ff8b89 100644
--- a/test/engine/test_reconnect.py
+++ b/test/engine/test_reconnect.py
@@ -1057,7 +1057,10 @@ class RealReconnectTest(fixtures.TestBase):
with self.engine.connect() as c1:
with patch.object(self.engine.pool, "logger") as logger:
- c1_branch = c1.connect()
+ with testing.expect_deprecated_20(
+ r"The Connection.connect\(\) method is considered legacy"
+ ):
+ c1_branch = c1.connect()
eq_(c1_branch.execute(select(1)).scalar(), 1)
self.engine.test_shutdown()
@@ -1074,8 +1077,10 @@ class RealReconnectTest(fixtures.TestBase):
def test_branched_invalidate_parent_to_branch(self):
with self.engine.connect() as c1:
-
- c1_branch = c1.connect()
+ with testing.expect_deprecated_20(
+ r"The Connection.connect\(\) method is considered legacy"
+ ):
+ c1_branch = c1.connect()
eq_(c1_branch.execute(select(1)).scalar(), 1)
self.engine.test_shutdown()
@@ -1090,8 +1095,10 @@ class RealReconnectTest(fixtures.TestBase):
def test_branch_invalidate_state(self):
with self.engine.connect() as c1:
-
- c1_branch = c1.connect()
+ with testing.expect_deprecated_20(
+ r"The Connection.connect\(\) method is considered legacy"
+ ):
+ c1_branch = c1.connect()
eq_(c1_branch.execute(select(1)).scalar(), 1)
diff --git a/test/orm/test_transaction.py b/test/orm/test_transaction.py
index fbd89616a..25f5d22ce 100644
--- a/test/orm/test_transaction.py
+++ b/test/orm/test_transaction.py
@@ -2941,7 +2941,10 @@ class LegacyBranchedJoinIntoAnExternalTransactionTest(
# neutron is doing this inside of a migration
# 1df244e556f5_add_unique_ha_router_agent_port_bindings.py
- self.session = Session(bind=self.connection.connect())
+ with testing.expect_deprecated_20(
+ r"The Connection.connect\(\) method is considered legacy"
+ ):
+ self.session = Session(bind=self.connection.connect())
if testing.requires.savepoints.enabled:
# start the session in a SAVEPOINT...