]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Modernize tests - Connection.connect
authorGord Thompson <gord@gordthompson.com>
Sat, 26 Jun 2021 16:17:57 +0000 (10:17 -0600)
committerGord Thompson <gord@gordthompson.com>
Sat, 26 Jun 2021 22:10:57 +0000 (16:10 -0600)
Change-Id: I61639dc2d7e7bcae6c53e2a15680b11fce3efa5d

lib/sqlalchemy/testing/warnings.py
test/engine/test_deprecations.py
test/engine/test_reconnect.py
test/orm/test_transaction.py

index fd774805081867b2aca3f7aeb8789e91ce2b743e..30f50a44f70c0b267c5e2622eea96a9e96dcb5e2 100644 (file)
@@ -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\(\)",
         #
         #
index fce9946dd7a1cf65b86d1c98139dc07031fb00c6..795cc5a4cf1efb88a1384b452cc88f5d3087709d 100644 (file)
@@ -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 "
index 70c4c51906406f213008f4f14ab1428f5df49ae4..538ff8b896db0e9000054001a3a7c13ed13ac159 100644 (file)
@@ -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)
 
index fbd89616afd3aacc58f31fedf1c8241d49363745..25f5d22ce878b90ce5c8f3748b74a0176046d209 100644 (file)
@@ -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...