diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-11-17 17:51:59 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-11-17 17:51:59 -0500 |
commit | ce3abfa79095605d402d2819d6580badf5318855 (patch) | |
tree | dd759759ed3c525379dad394e254ff92f8a5bf68 | |
parent | 45d77d0d4cfb4f0727d48c81543dc205e6621b01 (diff) | |
download | alembic-ce3abfa79095605d402d2819d6580badf5318855.tar.gz |
- restore the starting arg error back to the original intent
-rw-r--r-- | alembic/environment.py | 6 | ||||
-rw-r--r-- | tests/test_offline_environment.py | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/alembic/environment.py b/alembic/environment.py index a41c81d..279564c 100644 --- a/alembic/environment.py +++ b/alembic/environment.py @@ -179,10 +179,14 @@ class EnvironmentContext(object): if self._migration_context is not None: return self.script.as_revision_number( self.get_context()._start_from_rev) - elif self.context_opts.get('starting_rev') is not None: + elif 'starting_rev' in self.context_opts: return self.script.as_revision_number( self.context_opts['starting_rev']) else: + # this should raise only in the case that a command + # is being run where the "starting rev" is never applicable; + # this is to catch scripts which rely upon this in + # non-sql mode or similar raise util.CommandError( "No starting revision argument is available.") diff --git a/tests/test_offline_environment.py b/tests/test_offline_environment.py index b870dc4..f2695c2 100644 --- a/tests/test_offline_environment.py +++ b/tests/test_offline_environment.py @@ -53,14 +53,14 @@ assert context.get_starting_revision_argument() == 'x' command.upgrade(self.cfg, "x:y", sql=True) command.downgrade(self.cfg, "x:y", sql=True) - def test_starting_rev_pre_context_stamp(self): + def test_starting_rev_pre_context_cmd_w_no_startrev(self): env_file_fixture(""" assert context.get_starting_revision_argument() == 'x' """) assert_raises_message( util.CommandError, "No starting revision argument is available.", - command.stamp, self.cfg, a) + command.current, self.cfg) def test_starting_rev_current_pre_context(self): env_file_fixture(""" |