sqlalchemy-bot / test_alembic_1

0 stars 0 forks source link

nonexistent union_update() in custom imports rendering, also not tested at all #512

Closed sqlalchemy-bot closed 6 years ago

sqlalchemy-bot commented 6 years ago

Migrated issue, originally created by Michael Bayer (zzzeek)

this has been broken for a long time:

#!diff

diff --git a/tests/test_script_production.py b/tests/test_script_production.py
index 7ab46ab..af01a38 100644
--- a/tests/test_script_production.py
+++ b/tests/test_script_production.py
@@ -605,7 +605,7 @@ class ImportsTest(TestBase):
     def tearDown(self):
         clear_staging_env()

-    def _env_fixture(self, target_metadata):
+    def _env_fixture(self, target_metadata, **kw):
         self.engine = engine = _sqlite_file_db()

         def run_env(self):
@@ -614,7 +614,8 @@ class ImportsTest(TestBase):
             with engine.connect() as connection:
                 context.configure(
                     connection=connection,
-                    target_metadata=target_metadata)
+                    target_metadata=target_metadata,
+                    **kw)
                 with context.begin_transaction():
                     context.run_migrations()

@@ -636,13 +637,22 @@ class ImportsTest(TestBase):
             Column('x', type_)
         )

-        with self._env_fixture(m):
+        def process_revision_directives(context, rev, generate_revisions):
+            generate_revisions[0].imports.add(
+                "from sqlalchemy.dialects.mysql import TINYINT")
+
+        with self._env_fixture(
+                m,
+                process_revision_directives=process_revision_directives
+        ):
             rev = command.revision(
                 self.cfg, message="some message",
                 autogenerate=True)

         with open(rev.path) as file_:
-            assert "from sqlalchemy.dialects import mysql" in file_.read()
+            contents = file_.read()
+            assert "from sqlalchemy.dialects import mysql" in contents
+            assert "from sqlalchemy.dialects.mysql import TINYINT" in contents

 class MultiContextTest(TestBase):

see https://github.com/zzzeek/alembic/pull/46 for pr but we have to re-submit

sqlalchemy-bot commented 6 years ago

Michael Bayer (zzzeek) wrote:

https://gerrit.sqlalchemy.org/#/c/zzzeek/alembic/+/896

sqlalchemy-bot commented 6 years ago

Michael Bayer (zzzeek) wrote:

Replace union_update with update

Fixed issue where removed method union_update() was used when a customized :class:.MigrationScript instance included entries in the .imports data member, raising an AttributeError.

Change-Id: Ia141db106bc3d57238e2fa6a546041fd573c0ea4 Fixes: #512

→ 4848be786124