Commits

Mike Bayer committed 8f075a6

- [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

Comments (0)

Files changed (3)

   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.

alembic/script.py

 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+')
 
     @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"):

tests/test_revision_create.py

 
     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):
             "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"
         )
     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):