]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
python 3 works ! near zero changes needed
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 29 Nov 2011 18:10:25 +0000 (13:10 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 29 Nov 2011 18:10:25 +0000 (13:10 -0500)
CHANGES
setup.py
tests/__init__.py
tests/test_autogenerate.py

diff --git a/CHANGES b/CHANGES
index 490859a64b78f6bdbf2501f810887bcc16f6b18d..38b2049993643914e09d9fe9b45665244a453dce 100644 (file)
--- a/CHANGES
+++ b/CHANGES
   to the bugtracker, at 
   https://bitbucket.org/zzzeek/alembic/issues/new .
 
-- Python 3 is supported but has not yet
-  been tested.  The installer will run the 2to3
-  tool as needed, but there are probably some 
-  workarounds that will be needed to get Py3K 
-  fully running.
+- Python 3 is supported and has been tested.
 
 - The "Pylons" and "MultiDB" environment templates
   have not been directly tested - these should be 
index 7ed20d17b79a2955f297e3d6b839d6b94f233955..571e7e9e66be44ba186b605c8e500c54f2999024 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@ readme = os.path.join(os.path.dirname(__file__), 'README.rst')
 setup(name='alembic',
       version=VERSION,
       description="A database migration tool for SQLAlchemy.",
-      long_description=file(readme).read(),
+      long_description=open(readme).read(),
       classifiers=[
       'Development Status :: 3 - Alpha',
       'Environment :: Console',
index 4f81b58065e4f16d75f7272fa3ae42e4f8c7197a..e44e23b41aa647412feea0df7ade4805fe6b765f 100644 (file)
@@ -175,7 +175,7 @@ config = context.config
     if os.access(pyc_path, os.F_OK):
         os.unlink(pyc_path)
 
-    file(path, 'w').write(txt)
+    open(path, 'w').write(txt)
 
 def _sqlite_testing_config():
     dir_ = os.path.join(staging_directory, 'scripts')
index 0915fb519ca86490204f5463e6fa7f247ab57b4a..1f64db83399445cbb556986efdfa3f26d83aa6cb 100644 (file)
@@ -6,6 +6,9 @@ from unittest import TestCase
 from tests import staging_env, sqlite_db, clear_staging_env, eq_, \
         eq_ignore_whitespace, requires_07
 
+import sys
+py3k = sys.version_info >= (3, )
+
 def _model_one():
     m = MetaData()
 
@@ -155,8 +158,8 @@ class AutogenerateDiffTest(TestCase):
     sa.ForeignKeyConstraint([order_id], ['order.order_id'], ),
     sa.PrimaryKeyConstraint('id')
     )
-    drop_table(u'extra')
-    drop_column('user', u'pw')
+    drop_table(%(u)s'extra')
+    drop_column('user', %(u)s'pw')
     alter_column('user', 'a1', 
                existing_type=sa.TEXT(), 
                server_default='x', 
@@ -165,22 +168,24 @@ class AutogenerateDiffTest(TestCase):
                existing_type=sa.VARCHAR(length=50), 
                nullable=False)
     add_column('order', sa.Column('user_id', sa.Integer(), nullable=True))
-    alter_column('order', u'amount', 
+    alter_column('order', %(u)s'amount', 
                existing_type=sa.NUMERIC(precision=8, scale=2), 
                type_=sa.Numeric(precision=10, scale=2), 
                nullable=True, 
                existing_server_default='0')
     add_column('address', sa.Column('street', sa.String(length=50), nullable=True))
-    ### end Alembic commands ###""")
+    ### end Alembic commands ###""" % {
+        'u':"" if py3k else 'u'
+    })
 
         eq_(template_args['downgrades'],
 """### commands auto generated by Alembic - please adjust! ###
     drop_table('item')
-    create_table(u'extra',
-    sa.Column(u'x', sa.CHAR(), nullable=True),
+    create_table(%(u)s'extra',
+    sa.Column(%(u)s'x', sa.CHAR(), nullable=True),
     sa.PrimaryKeyConstraint()
     )
-    add_column('user', sa.Column(u'pw', sa.VARCHAR(length=50), nullable=True))
+    add_column('user', sa.Column(%(u)s'pw', sa.VARCHAR(length=50), nullable=True))
     alter_column('user', 'a1', 
                existing_type=sa.TEXT(), 
                server_default=None, 
@@ -189,13 +194,15 @@ class AutogenerateDiffTest(TestCase):
                existing_type=sa.VARCHAR(length=50), 
                nullable=True)
     drop_column('order', 'user_id')
-    alter_column('order', u'amount', 
+    alter_column('order', %(u)s'amount', 
                existing_type=sa.Numeric(precision=10, scale=2), 
                type_=sa.NUMERIC(precision=8, scale=2), 
                nullable=False, 
                existing_server_default='0')
     drop_column('address', 'street')
-    ### end Alembic commands ###""")
+    ### end Alembic commands ###""" % {
+        'u':"" if py3k else 'u'
+    })
 
     def test_skip_null_type_comparison_reflected(self):
         diff = []