From 6ecce8996188a63ba18c607dd10dd58c9c21f2b8 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 16 Aug 2021 12:53:46 +0100 Subject: Don't call 'begin()' on existing transaction Resolve the following RemovedIn20Warning warning: Calling .begin() when a transaction is already begun, creating a 'sub' transaction, is deprecated and will be removed in 2.0. See the documentation section 'Migrating from the nesting pattern' for background on how to migrate from this pattern. Change-Id: I59e45dfea8fcbf72fc6e34345e510554cbdd138e Signed-off-by: Stephen Finucane --- oslo_db/tests/fixtures.py | 5 ----- oslo_db/tests/sqlalchemy/test_utils.py | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'oslo_db') diff --git a/oslo_db/tests/fixtures.py b/oslo_db/tests/fixtures.py index 4646278..468dcae 100644 --- a/oslo_db/tests/fixtures.py +++ b/oslo_db/tests/fixtures.py @@ -45,11 +45,6 @@ class WarningsFixture(fixtures.Fixture): message=r'The Session.autocommit parameter is deprecated .*', category=sqla_exc.SADeprecationWarning) - warnings.filterwarnings( - 'once', - message=r'Calling \.begin\(\) when a transaction is already .*', - category=sqla_exc.SADeprecationWarning) - # ...plus things that aren't our fault # FIXME(stephenfin): These are caused by sqlalchemy-migrate, not us, diff --git a/oslo_db/tests/sqlalchemy/test_utils.py b/oslo_db/tests/sqlalchemy/test_utils.py index 087f7ec..27ed640 100644 --- a/oslo_db/tests/sqlalchemy/test_utils.py +++ b/oslo_db/tests/sqlalchemy/test_utils.py @@ -700,8 +700,7 @@ class TestMigrationUtils(db_test_base._DbTestCase): test_table.create(engine) with engine.connect() as conn, conn.begin(): - with conn.begin(): - conn.execute(test_table.insert(), values) + conn.execute(test_table.insert(), values) return test_table, values def test_drop_old_duplicate_entries_from_table(self): -- cgit v1.2.1