]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Mock engines take on the .name of their dialect. [ticket:1123]
authorJason Kirtland <jek@discorporate.us>
Fri, 15 Aug 2008 23:17:24 +0000 (23:17 +0000)
committerJason Kirtland <jek@discorporate.us>
Fri, 15 Aug 2008 23:17:24 +0000 (23:17 +0000)
  Slightly backward incompatible: the .name is a read-only property.
  The test suite was assigning .name = 'mock'; this no longer works.

lib/sqlalchemy/engine/strategies.py
test/engine/ddlevents.py

index c9e65982ef074e8ae596a22c402d3273cb7f2290..62a4b9bb849d1557ccd2b1d709d6d563af88b497 100644 (file)
@@ -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
index 9894a290050838de69f33e655bd05a131cda69bc..8274c63476ea01ea1e45de32e749bba074163429 100644 (file)
@@ -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').