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 <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2021-08-16 12:53:46 +01:00
parent 22c602f075
commit 6ecce89961
2 changed files with 1 additions and 7 deletions

View File

@ -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,

View File

@ -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):