]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- [bug] Fixed the regexp that was checking for .py files
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 30 Sep 2012 16:37:02 +0000 (12:37 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 30 Sep 2012 16:37:02 +0000 (12:37 -0400)
  in the version directory to allow any .py file through.
  Previously it was doing some kind of defensive checking,
  probably from some early notions of how this directory
  works, that was prohibiting various filename patterns
  such as those which begin with numbers.  #72

CHANGES
alembic/script.py
tests/test_revision_create.py

diff --git a/CHANGES b/CHANGES
index 84d5c9202ac3ce2e7a2df8360b88edd5c53ff564..3ee614e5148af1bafc6a45748e87d0aa6b0d4cae 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,13 @@
   front-ends can re-use the argument parsing built
   in.  #70
 
+- [bug] Fixed the regexp that was checking for .py files
+  in the version directory to allow any .py file through.
+  Previously it was doing some kind of defensive checking,
+  probably from some early notions of how this directory
+  works, that was prohibiting various filename patterns
+  such as those which begin with numbers.  #72
+
 - [bug] Fixed MySQL rendering for server_default which
   didn't work if the server_default was a generated
   SQL expression.  Courtesy Moriyoshi Koizumi.
index e888a3e4920aceaa2edb5c4c5868d6ceb59086aa..b411fb9775f36953725ec0ed320c41fbb2cc68ec 100644 (file)
@@ -4,10 +4,9 @@ import os
 from alembic import util
 import shutil
 import re
-import inspect
 import datetime
 
-_rev_file = re.compile(r'([a-z0-9A-Z]+)(?:_.*)?\.py$')
+_rev_file = re.compile(r'.*\.py$')
 _legacy_rev = re.compile(r'([a-f0-9]+)\.py$')
 _mod_def_re = re.compile(r'(upgrade|downgrade)_([a-z0-9]+)')
 _slug_re = re.compile(r'\w+')
@@ -418,8 +417,7 @@ class Script(object):
 
     @classmethod
     def _from_filename(cls, dir_, filename):
-        m = _rev_file.match(filename)
-        if not m:
+        if not _rev_file.match(filename):
             return None
         module = util.load_python_file(dir_, filename)
         if not hasattr(module, "revision"):
index dcaf2064f954c7464bb85a0de3e3d672a0548dfa..78a628a29c6d749df3bf8214b555b9eba144b6d8 100644 (file)
@@ -70,12 +70,14 @@ class GeneralOrderedTests(unittest.TestCase):
 
     def test_008_long_name(self):
         rid = util.rev_id()
-        script = env.generate_revision(rid,
+        env.generate_revision(rid,
                 "this is a really long name with "
                 "lots of characters and also "
                 "I'd like it to\nhave\nnewlines")
         assert os.access(
-            os.path.join(env.dir, 'versions', '%s_this_is_a_really_lon.py' % rid), os.F_OK)
+            os.path.join(env.dir, 'versions',
+                        '%s_this_is_a_really_lon.py' % rid), os.F_OK)
+
 
     @classmethod
     def setup_class(cls):
@@ -110,9 +112,10 @@ class ScriptNamingTest(unittest.TestCase):
             "message_2012_5_25_15_5_5.py" % staging_directory
         )
 
+
 class TemplateArgsTest(unittest.TestCase):
     def setUp(self):
-        env = staging_env()
+        staging_env()
         self.cfg = _no_sql_testing_config(
             directives="\nrevision_environment=true\n"
         )
@@ -123,17 +126,17 @@ class TemplateArgsTest(unittest.TestCase):
     def test_args_propagate(self):
         config = _no_sql_testing_config()
         script = ScriptDirectory.from_config(config)
-        template_args = {"x":"x1", "y":"y1", "z":"z1"}
+        template_args = {"x": "x1", "y": "y1", "z": "z1"}
         env = EnvironmentContext(
             config,
             script,
-            template_args = template_args
+            template_args=template_args
         )
-        mig_env = env.configure(dialect_name="sqlite",
-                        template_args={"y":"y2", "q":"q1"})
+        env.configure(dialect_name="sqlite",
+                        template_args={"y": "y2", "q": "q1"})
         eq_(
             template_args,
-            {"x":"x1", "y":"y2", "z":"z1", "q":"q1"}
+            {"x": "x1", "y": "y2", "z": "z1", "q": "q1"}
         )
 
     def test_tmpl_args_revision(self):