]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- [bug] 'alembic' command reports an informative
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 28 Jul 2012 10:48:16 +0000 (06:48 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 28 Jul 2012 10:48:16 +0000 (06:48 -0400)
  error message when the configuration is missing
  the 'script_directory' key.  #63

CHANGES
alembic/script.py
tests/test_config.py

diff --git a/CHANGES b/CHANGES
index 7f2220a0d4bc6266fb39b9eb9859bc1950d0223c..a66265d4b59786b7b5a1313384fe9a512cbec9fc 100644 (file)
--- a/CHANGES
+++ b/CHANGES
   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
index efbde8d54f4d3659b4eeef7129c8069340ba4fcf..286a3d4327e67eeba89061f116774906f21343c3 100644 (file)
@@ -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)
index f0bd16743035a98a000d5a606aa868cb379258df..0b6df76af4b94d8bec0511b4de1a04a37b2d67f5 100644 (file)
@@ -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
+    )