summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2008-08-15 23:17:24 +0000
committerJason Kirtland <jek@discorporate.us>2008-08-15 23:17:24 +0000
commit10848388a385a5619a5a626abea2e1ddf10d36d6 (patch)
treeaff35aa6e7fdd08947494cccd7fcbadbf196ef1f
parent4556f4b3dfcb9d8e443042f6d61204e01c7086df (diff)
downloadsqlalchemy-10848388a385a5619a5a626abea2e1ddf10d36d6.tar.gz
- Mock engines take on the .name of their dialect. [ticket:1123]
Slightly backward incompatible: the .name is a read-only property. The test suite was assigning .name = 'mock'; this no longer works.
-rw-r--r--lib/sqlalchemy/engine/strategies.py21
-rw-r--r--test/engine/ddlevents.py4
2 files changed, 13 insertions, 12 deletions
diff --git a/lib/sqlalchemy/engine/strategies.py b/lib/sqlalchemy/engine/strategies.py
index c9e65982e..62a4b9bb8 100644
--- a/lib/sqlalchemy/engine/strategies.py
+++ b/lib/sqlalchemy/engine/strategies.py
@@ -1,20 +1,20 @@
"""Strategies for creating new instances of Engine types.
-These are semi-private implementation classes which
-provide the underlying behavior for the "strategy" keyword argument
-available on [sqlalchemy.engine#create_engine()].
-Current available options are ``plain``, ``threadlocal``, and
-``mock``.
-
-New strategies can be added via new ``EngineStrategy``
-classes.
-"""
+These are semi-private implementation classes which provide the
+underlying behavior for the "strategy" keyword argument available on
+[sqlalchemy.engine#create_engine()]. Current available options are
+``plain``, ``threadlocal``, and ``mock``.
+
+New strategies can be added via new ``EngineStrategy`` classes.
+"""
+from operator import attrgetter
from sqlalchemy.engine import base, threadlocal, url
from sqlalchemy import util, exc
from sqlalchemy import pool as poollib
+
strategies = {}
class EngineStrategy(object):
@@ -189,7 +189,8 @@ class MockEngineStrategy(EngineStrategy):
self.execute = execute
engine = property(lambda s: s)
- dialect = property(lambda s:s._dialect)
+ dialect = property(attrgetter('_dialect'))
+ name = property(lambda s: s._dialect.name)
def contextual_connect(self, **kwargs):
return self
diff --git a/test/engine/ddlevents.py b/test/engine/ddlevents.py
index 9894a2900..8274c6347 100644
--- a/test/engine/ddlevents.py
+++ b/test/engine/ddlevents.py
@@ -319,12 +319,12 @@ class DDLTest(TestBase):
'S S-T T-"s s"."t t"-b')
def test_filter(self):
cx = self.mock_engine()
- cx.name = 'mock'
tbl = Table('t', MetaData(), Column('id', Integer))
+ target = cx.name
assert DDL('')._should_execute('x', tbl, cx)
- assert DDL('', on='mock')._should_execute('x', tbl, cx)
+ assert DDL('', on=target)._should_execute('x', tbl, cx)
assert not DDL('', on='bogus')._should_execute('x', tbl, cx)
assert DDL('', on=lambda x,y,z: True)._should_execute('x', tbl, cx)
assert(DDL('', on=lambda x,y,z: z.engine.name != 'bogus').