From bd8a8dc60dafcfc9e6750d2a48c51b8fc5df0e28 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 25 May 2014 14:23:54 -0400 Subject: [PATCH] - changelog + test for MigrationContext.config --- alembic/migration.py | 6 +++++- docs/build/changelog.rst | 12 ++++++++++++ tests/test_environment.py | 12 ++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/alembic/migration.py b/alembic/migration.py index 0fffbe5b..e5de70f3 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 fb437b6f..1a00cbcb 100644 --- a/docs/build/changelog.rst +++ b/docs/build/changelog.rst @@ -2,6 +2,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 d7a4554a..cc5ccb88 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) -- 2.47.2