From: Mike Bayer Date: Sun, 30 Sep 2012 16:37:02 +0000 (-0400) Subject: - [bug] Fixed the regexp that was checking for .py files X-Git-Tag: rel_0_4_0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3f20c640ab8a2a219bb5a158cd666546dcf8d58;p=thirdparty%2Fsqlalchemy%2Falembic.git - [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 --- diff --git a/CHANGES b/CHANGES index 84d5c920..3ee614e5 100644 --- 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. diff --git a/alembic/script.py b/alembic/script.py index e888a3e4..b411fb97 100644 --- a/alembic/script.py +++ b/alembic/script.py @@ -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"): diff --git a/tests/test_revision_create.py b/tests/test_revision_create.py index dcaf2064..78a628a2 100644 --- a/tests/test_revision_create.py +++ b/tests/test_revision_create.py @@ -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):