[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
This commit is contained in:
yatinkarel 2023-09-04 13:33:29 +05:30 committed by yatin
parent 9716e0356d
commit f7489abaf8
1 changed files with 5 additions and 2 deletions

View File

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