From f7489abaf822574f6d8c01b72495788e07d756d3 Mon Sep 17 00:00:00 2001 From: yatinkarel Date: Mon, 4 Sep 2023 13:33:29 +0530 Subject: [PATCH] [UT] Adjust autogen_process_directives for alembic-1.12.0+ With [1] included in alembic-1.12.0 the unit test test_autogen_process_directives fails as it was expecting 'type_' param in Autogenerated output. But this is not included with 1.12.0 by default, this patch enhances the regex to care only for relevant parameters. [1] https://github.com/sqlalchemy/alembic/commit/733197e Closes-Bug: #2034016 Change-Id: I088cc4b260cccf6be2963d23a76a05f11cfccf2c --- neutron/tests/unit/db/test_migration.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/neutron/tests/unit/db/test_migration.py b/neutron/tests/unit/db/test_migration.py index 581a8c412fb..6520bb9ecdd 100644 --- a/neutron/tests/unit/db/test_migration.py +++ b/neutron/tests/unit/db/test_migration.py @@ -682,7 +682,10 @@ class TestCli(base.BaseTestCase): s = textwrap.dedent(s) s = re.escape(s) # alembic 0.8.9 added additional leading '# ' before comments - return s.replace('\\#\\#\\#\\ ', '(# )?### ') + s = s.replace('\\#\\#\\#\\ ', '(# )?### ') + # alembic 1.12.0 Autogenerate includes type_ option conditionally + s = s.replace('\\.\\*', '.*') + return s expected_regex = ("""\ ### commands auto generated by Alembic - please adjust! ### @@ -702,7 +705,7 @@ class TestCli(base.BaseTestCase): expected_regex = ("""\ ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('user', 'uq_user_org', type_=None) + op.drop_constraint('user', 'uq_user_org'.*) op.drop_column('user', 'organization_name') ### end Alembic commands ###""") self.assertThat(