From: Gord Thompson Date: Sat, 26 Jun 2021 16:17:57 +0000 (-0600) Subject: Modernize tests - Connection.connect X-Git-Tag: rel_1_4_21~21^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e91400f1b35520af838131718fc170235799a5b;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Modernize tests - Connection.connect Change-Id: I61639dc2d7e7bcae6c53e2a15680b11fce3efa5d --- diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py index fd77480508..30f50a44f7 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 fce9946dd7..795cc5a4cf 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 70c4c51906..538ff8b896 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 fbd89616af..25f5d22ce8 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...