summaryrefslogtreecommitdiff
path: root/tests/__init__.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-01-24 12:20:33 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-01-24 12:20:33 -0500
commit72416bcde500f48a66310eafc86c071ee2672d09 (patch)
treeb732616341f29e5b5105b02ae749ade44c6bcdb3 /tests/__init__.py
parent228ceec575ed45b251d98367a05d58a3e4321934 (diff)
downloadalembic-72416bcde500f48a66310eafc86c071ee2672d09.tar.gz
- rearrange the internals such that we no longer use global
variables to get to things. The new structure is: EnvironmentContext -> MigrationContext -> Operation EnvironmentContext sets up the variables "alembic.context" and "alembic.op" to act like the modules they used to. MigrationContext can also exist independently of EnvironmentContext. Refactoring is still underway here.
Diffstat (limited to 'tests/__init__.py')
-rw-r--r--tests/__init__.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index 4d84331..328040a 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -5,10 +5,12 @@ import shutil
import os
import itertools
from sqlalchemy import create_engine, text, MetaData
-from alembic import context, util
+from alembic import util
+from alembic.migration import MigrationContext
import re
+import alembic
+from alembic.operations import Operations
from alembic.script import ScriptDirectory
-from alembic.context import Context
from alembic import ddl
import StringIO
from alembic.ddl.impl import _impls
@@ -140,12 +142,11 @@ def op_fixture(dialect='default', as_sql=False):
)
- class ctx(Context):
+ class ctx(MigrationContext):
def __init__(self, dialect='default', as_sql=False):
self.dialect = _get_dialect(dialect)
self.impl = Impl(self.dialect, as_sql)
- context._context = self
self.as_sql = as_sql
def assert_(self, *sql):
@@ -162,7 +163,9 @@ def op_fixture(dialect='default', as_sql=False):
sql,
self.impl.assertion
)
- return ctx(dialect, as_sql)
+ context = ctx(dialect, as_sql)
+ alembic.op._proxy = Operations(context)
+ return context
def env_file_fixture(txt):
dir_ = os.path.join(staging_directory, 'scripts')
@@ -269,12 +272,10 @@ def staging_env(create=True, template="generic"):
shutil.rmtree(path)
command.init(cfg, path)
sc = script.ScriptDirectory.from_config(cfg)
- context._opts(cfg,sc, fn=lambda:None)
return sc
def clear_staging_env():
shutil.rmtree(staging_directory, True)
- context._clear()
def three_rev_fixture(cfg):
a = util.rev_id()