From: Mike Bayer Date: Sat, 28 Jul 2012 10:48:16 +0000 (-0400) Subject: - [bug] 'alembic' command reports an informative X-Git-Tag: rel_0_3_6~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56bdf6c98fb3a5a4a6bb481bf108b08a6cd83616;p=thirdparty%2Fsqlalchemy%2Falembic.git - [bug] 'alembic' command reports an informative error message when the configuration is missing the 'script_directory' key. #63 --- diff --git a/CHANGES b/CHANGES index 7f2220a0..a66265d4 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,10 @@ config option is being used but SQL access isn't desired. +- [bug] 'alembic' command reports an informative + error message when the configuration is missing + the 'script_directory' key. #63 + 0.3.5 ===== - [bug] Fixed issue whereby reflected server defaults diff --git a/alembic/script.py b/alembic/script.py index efbde8d5..286a3d43 100644 --- a/alembic/script.py +++ b/alembic/script.py @@ -52,10 +52,12 @@ class ScriptDirectory(object): present. """ + script_location = config.get_main_option('script_location') + if script_location is None: + raise util.CommandError("No 'script_location' key " + "found in configuration.") return ScriptDirectory( - util.coerce_resource_to_filename( - config.get_main_option('script_location') - ), + util.coerce_resource_to_filename(script_location), file_template = config.get_main_option( 'file_template', _default_file_template) diff --git a/tests/test_config.py b/tests/test_config.py index f0bd1674..0b6df76a 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,7 +1,9 @@ from alembic import config from alembic.migration import MigrationContext from alembic.operations import Operations -from tests import eq_, capture_db +from alembic import util +from alembic.script import ScriptDirectory +from tests import eq_, capture_db, assert_raises_message def test_config_no_file_main_option(): cfg = config.Config() @@ -28,3 +30,11 @@ def test_standalone_op(): op.alter_column("t", "c", nullable=True) eq_(buf, ['ALTER TABLE t ALTER COLUMN c DROP NOT NULL']) + +def test_no_script_error(): + cfg = config.Config() + assert_raises_message( + util.CommandError, + "No 'script_location' key found in configuration.", + ScriptDirectory.from_config, cfg + )