From: Mike Bayer Date: Fri, 27 Dec 2013 15:25:51 +0000 (-0500) Subject: - Fixed bug in the not-internally-used :meth:`.ScriptDirectory.get_base` X-Git-Tag: rel_0_6_2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0fbd149c4dc58488967eb2828a101ebaad1b5c8;p=thirdparty%2Fsqlalchemy%2Falembic.git - Fixed bug in the not-internally-used :meth:`.ScriptDirectory.get_base` method which would fail if called on an empty versions directory. --- diff --git a/alembic/script.py b/alembic/script.py index cd28d7a1..34fd1500 100644 --- a/alembic/script.py +++ b/alembic/script.py @@ -297,7 +297,7 @@ class ScriptDirectory(object): """ for script in self._revision_map.values(): - if script.down_revision is None \ + if script and script.down_revision is None \ and script.revision in self._revision_map: return script.revision else: diff --git a/docs/build/changelog.rst b/docs/build/changelog.rst index a8488413..088018ef 100644 --- a/docs/build/changelog.rst +++ b/docs/build/changelog.rst @@ -6,6 +6,12 @@ Changelog .. changelog:: :version: 0.6.2 + .. change:: + :tags: bug + + Fixed bug in the not-internally-used :meth:`.ScriptDirectory.get_base` + method which would fail if called on an empty versions directory. + .. change:: :tags: bug :tickets: 157 diff --git a/tests/test_revision_create.py b/tests/test_revision_create.py index aa85809b..07ed6d44 100644 --- a/tests/test_revision_create.py +++ b/tests/test_revision_create.py @@ -24,9 +24,11 @@ class GeneralOrderedTests(unittest.TestCase): def_ = util.rev_id() ne_(abc, def_) - def test_003_heads(self): + def test_003_api_methods_clean(self): eq_(env.get_heads(), []) + eq_(env.get_base(), None) + def test_004_rev(self): script = env.generate_revision(abc, "this is a message", refresh=True) eq_(script.doc, "this is a message") @@ -36,6 +38,7 @@ class GeneralOrderedTests(unittest.TestCase): os.path.join(env.dir, 'versions', '%s_this_is_a_message.py' % abc), os.F_OK) assert callable(script.module.upgrade) eq_(env.get_heads(), [abc]) + eq_(env.get_base(), abc) def test_005_nextrev(self): script = env.generate_revision(def_, "this is the next rev", refresh=True) @@ -48,6 +51,7 @@ class GeneralOrderedTests(unittest.TestCase): assert callable(script.module.upgrade) assert callable(script.module.downgrade) eq_(env.get_heads(), [def_]) + eq_(env.get_base(), abc) def test_006_from_clean_env(self): # test the environment so far with a @@ -60,6 +64,7 @@ class GeneralOrderedTests(unittest.TestCase): eq_(abc_rev.revision, abc) eq_(def_rev.down_revision, abc) eq_(env.get_heads(), [def_]) + eq_(env.get_base(), abc) def test_007_no_refresh(self): rid = util.rev_id()