diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-05-25 14:23:54 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-05-25 14:23:54 -0400 |
commit | bd8a8dc60dafcfc9e6750d2a48c51b8fc5df0e28 (patch) | |
tree | 42404caf431edd75a50129b5d13f77902fb9a65e | |
parent | ab4a402fdb9bf45ad0990c44fd12ff50d19160f5 (diff) | |
download | alembic-bd8a8dc60dafcfc9e6750d2a48c51b8fc5df0e28.tar.gz |
- changelog + test for MigrationContext.config
-rw-r--r-- | alembic/migration.py | 6 | ||||
-rw-r--r-- | docs/build/changelog.rst | 12 | ||||
-rw-r--r-- | tests/test_environment.py | 12 |
3 files changed, 27 insertions, 3 deletions
diff --git a/alembic/migration.py b/alembic/migration.py index 0fffbe5..e5de70f 100644 --- a/alembic/migration.py +++ b/alembic/migration.py @@ -309,7 +309,11 @@ class MigrationContext(object): @property def config(self): - """Return the :class:`.Config` used by the current environment, if any.""" + """Return the :class:`.Config` used by the current environment, if any. + + .. versionadded:: 0.6.6 + + """ if self.environment_context: return self.environment_context.config else: diff --git a/docs/build/changelog.rst b/docs/build/changelog.rst index fb437b6..1a00cbc 100644 --- a/docs/build/changelog.rst +++ b/docs/build/changelog.rst @@ -3,6 +3,18 @@ Changelog ========== .. changelog:: + :version: 0.6.6 + + .. change:: + :tags: feature + :pullreq: github:10 + + Added a new accessor :attr:`.MigrationContext.config`, when used + in conjunction with a :class:`.EnvironmentContext` and + :class:`.Config`, this config will be returned. Patch + courtesy Marc Abramowitz. + +.. changelog:: :version: 0.6.5 :released: May 3, 2014 diff --git a/tests/test_environment.py b/tests/test_environment.py index d7a4554..cc5ccb8 100644 --- a/tests/test_environment.py +++ b/tests/test_environment.py @@ -1,12 +1,12 @@ #!coding: utf-8 -from alembic.config import Config from alembic.script import ScriptDirectory from alembic.environment import EnvironmentContext +from alembic.migration import MigrationContext import unittest from . import Mock, call, _no_sql_testing_config, staging_env, clear_staging_env -from . import eq_ +from . import eq_, is_ class EnvironmentTest(unittest.TestCase): def setUp(self): @@ -62,3 +62,11 @@ class EnvironmentTest(unittest.TestCase): "x" ) + def test_migration_context_has_config(self): + env = self._fixture() + env.configure(url="sqlite://") + ctx = env._migration_context + is_(ctx.config, self.cfg) + + ctx = MigrationContext(ctx.dialect, None, {}) + is_(ctx.config, None) |