summaryrefslogtreecommitdiff
path: root/test/testlib
diff options
context:
space:
mode:
authorMichael Trier <mtrier@gmail.com>2008-07-08 01:37:38 +0000
committerMichael Trier <mtrier@gmail.com>2008-07-08 01:37:38 +0000
commitcec5947b5ba09f430d683625e695d64e09210ef1 (patch)
tree6275b1bbf35932dcbcc1cbe87e77f633e0a256ba /test/testlib
parent93c706a03bc809e21208cb6e9f76b23ed6d2ff19 (diff)
downloadsqlalchemy-cec5947b5ba09f430d683625e695d64e09210ef1.tar.gz
Refactored the mock_engine in the tests so it's not duplicated in several places. Closes #1098
Diffstat (limited to 'test/testlib')
-rw-r--r--test/testlib/engines.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/testlib/engines.py b/test/testlib/engines.py
index 5ad35a066..181cb005d 100644
--- a/test/testlib/engines.py
+++ b/test/testlib/engines.py
@@ -1,8 +1,8 @@
import sys, types, weakref
-from testlib import config
+from sqlalchemy import create_engine
+from testlib import config, testing
from testlib.compat import set, _function_named, deque
-
class ConnectionKiller(object):
def __init__(self):
self.proxy_refs = weakref.WeakKeyDictionary()
@@ -132,6 +132,18 @@ def utf8_engine(url=None, options=None):
return testing_engine(url, options)
+def mock_engine(db=None):
+ """Provides a mocking engine based on the current testing.db."""
+
+ dbi = db or testing.db
+ buffer = []
+ def executor(sql, *a, **kw):
+ buffer.append(sql)
+ engine = create_engine(dbi.name + '://',
+ strategy='mock', executor=executor)
+ assert not hasattr(engine, 'mock')
+ engine.mock = buffer
+ return engine
class ReplayableSession(object):
"""A simple record/playback tool.