summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2021-11-07 21:19:45 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2021-11-07 21:19:45 +0000
commit201c00bc0837af831f115e8313ad3ccb0be97e7a (patch)
treebeb7558e95d073b63fa4bb76d830ccaa2de9711a /lib/sqlalchemy/testing
parent5b1c9053b0903b2d5a06f82b47fe16a870696ddc (diff)
parentd050193daaa8d91371c759296f3304b8641c1976 (diff)
downloadsqlalchemy-201c00bc0837af831f115e8313ad3ccb0be97e7a.tar.gz
Merge "fully implement future engine and remove legacy" into main
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/assertsql.py11
-rw-r--r--lib/sqlalchemy/testing/engines.py30
-rw-r--r--lib/sqlalchemy/testing/fixtures.py26
-rw-r--r--lib/sqlalchemy/testing/suite/test_dialect.py1
-rw-r--r--lib/sqlalchemy/testing/suite/test_results.py14
5 files changed, 24 insertions, 58 deletions
diff --git a/lib/sqlalchemy/testing/assertsql.py b/lib/sqlalchemy/testing/assertsql.py
index 4ee4c5844..ca0bc6726 100644
--- a/lib/sqlalchemy/testing/assertsql.py
+++ b/lib/sqlalchemy/testing/assertsql.py
@@ -13,7 +13,6 @@ from .. import event
from .. import util
from ..engine import url
from ..engine.default import DefaultDialect
-from ..engine.util import _distill_cursor_params
from ..schema import _DDLCompiles
@@ -370,9 +369,13 @@ class SQLExecuteObserved(object):
def __init__(self, context, clauseelement, multiparams, params):
self.context = context
self.clauseelement = clauseelement
- self.parameters = _distill_cursor_params(
- context.connection, tuple(multiparams), params
- )
+
+ if multiparams:
+ self.parameters = multiparams
+ elif params:
+ self.parameters = [params]
+ else:
+ self.parameters = []
self.statements = []
def __repr__(self):
diff --git a/lib/sqlalchemy/testing/engines.py b/lib/sqlalchemy/testing/engines.py
index a54f70c5e..815009e78 100644
--- a/lib/sqlalchemy/testing/engines.py
+++ b/lib/sqlalchemy/testing/engines.py
@@ -269,7 +269,6 @@ def reconnecting_engine(url=None, options=None):
def testing_engine(
url=None,
options=None,
- future=None,
asyncio=False,
transfer_staticpool=False,
):
@@ -277,10 +276,6 @@ def testing_engine(
if asyncio:
from sqlalchemy.ext.asyncio import create_async_engine as create_engine
- elif future or (
- config.db and config.db._is_future and future is not False
- ):
- from sqlalchemy.future import create_engine
else:
from sqlalchemy import create_engine
from sqlalchemy.engine.url import make_url
@@ -417,28 +412,3 @@ class DBAPIProxyConnection(object):
def __getattr__(self, key):
return getattr(self.conn, key)
-
-
-def proxying_engine(
- conn_cls=DBAPIProxyConnection, cursor_cls=DBAPIProxyCursor
-):
- """Produce an engine that provides proxy hooks for
- common methods.
-
- """
-
- def mock_conn():
- return conn_cls(config.db, cursor_cls)
-
- def _wrap_do_on_connect(do_on_connect):
- def go(dbapi_conn):
- return do_on_connect(dbapi_conn.conn)
-
- return go
-
- return testing_engine(
- options={
- "creator": mock_conn,
- "_wrap_do_on_connect": _wrap_do_on_connect,
- }
- )
diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py
index f04056c5e..1899e5b7c 100644
--- a/lib/sqlalchemy/testing/fixtures.py
+++ b/lib/sqlalchemy/testing/fixtures.py
@@ -5,7 +5,6 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: https://www.opensource.org/licenses/mit-license.php
-import contextlib
import re
import sys
@@ -93,9 +92,7 @@ class TestBase(object):
@config.fixture()
def future_engine(self):
- eng = getattr(self, "bind", None) or config.db
- with _push_future_engine(eng):
- yield
+ yield
@config.fixture()
def testing_engine(self):
@@ -114,7 +111,6 @@ class TestBase(object):
return engines.testing_engine(
url=url,
options=options,
- future=future,
asyncio=asyncio,
transfer_staticpool=transfer_staticpool,
)
@@ -303,26 +299,8 @@ class TestBase(object):
_connection_fixture_connection = None
-@contextlib.contextmanager
-def _push_future_engine(engine):
-
- from ..future.engine import Engine
- from sqlalchemy import testing
-
- facade = Engine._future_facade(engine)
- config._current.push_engine(facade, testing)
-
- yield facade
-
- config._current.pop(testing)
-
-
class FutureEngineMixin(object):
- @config.fixture(autouse=True, scope="class")
- def _push_future_engine(self):
- eng = getattr(self, "bind", None) or config.db
- with _push_future_engine(eng):
- yield
+ """alembic's suite still using this"""
class TablesTest(TestBase):
diff --git a/lib/sqlalchemy/testing/suite/test_dialect.py b/lib/sqlalchemy/testing/suite/test_dialect.py
index 32dfdedad..b3e43aad0 100644
--- a/lib/sqlalchemy/testing/suite/test_dialect.py
+++ b/lib/sqlalchemy/testing/suite/test_dialect.py
@@ -170,6 +170,7 @@ class AutocommitIsolationTest(fixtures.TablesTest):
conn.scalar(select(self.tables.some_table.c.id)),
1 if autocommit else None,
)
+ conn.rollback()
with conn.begin():
conn.execute(self.tables.some_table.delete())
diff --git a/lib/sqlalchemy/testing/suite/test_results.py b/lib/sqlalchemy/testing/suite/test_results.py
index c41a55025..f470432d2 100644
--- a/lib/sqlalchemy/testing/suite/test_results.py
+++ b/lib/sqlalchemy/testing/suite/test_results.py
@@ -323,6 +323,20 @@ class ServerSideCursorsTest(
).exec_driver_sql("select 1")
assert self._is_server_side(result.cursor)
+ # the connection has autobegun, which means at the end of the
+ # block, we will roll back, which on MySQL at least will fail
+ # with "Commands out of sync" if the result set
+ # is not closed, so we close it first.
+ #
+ # fun fact! why did we not have this result.close() in this test
+ # before 2.0? don't we roll back in the connection pool
+ # unconditionally? yes! and in fact if you run this test in 1.4
+ # with stdout shown, there is in fact "Exception during reset or
+ # similar" with "Commands out sync" emitted a warning! 2.0's
+ # architecture finds and fixes what was previously an expensive
+ # silent error condition.
+ result.close()
+
def test_stmt_enabled_conn_option_disabled(self):
engine = self._fixture(False)