@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:
==========
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
#!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):
"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)