summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/engines.py14
-rw-r--r--lib/sqlalchemy/testing/fixtures.py7
-rw-r--r--lib/sqlalchemy/testing/requirements.py10
-rw-r--r--lib/sqlalchemy/testing/suite/test_dialect.py14
-rw-r--r--lib/sqlalchemy/testing/suite/test_results.py13
5 files changed, 49 insertions, 9 deletions
diff --git a/lib/sqlalchemy/testing/engines.py b/lib/sqlalchemy/testing/engines.py
index a313c298a..3faf96857 100644
--- a/lib/sqlalchemy/testing/engines.py
+++ b/lib/sqlalchemy/testing/engines.py
@@ -266,7 +266,13 @@ def reconnecting_engine(url=None, options=None):
return engine
-def testing_engine(url=None, options=None, future=None, asyncio=False):
+def testing_engine(
+ url=None,
+ options=None,
+ future=None,
+ asyncio=False,
+ transfer_staticpool=False,
+):
"""Produce an engine configured by --options with optional overrides."""
if asyncio:
@@ -300,6 +306,12 @@ def testing_engine(url=None, options=None, future=None, asyncio=False):
engine = create_engine(url, **options)
+ if transfer_staticpool:
+ from sqlalchemy.pool import StaticPool
+
+ if config.db is not None and isinstance(config.db.pool, StaticPool):
+ engine.pool._transfer_from(config.db.pool)
+
if scope == "global":
if asyncio:
engine.sync_engine._has_events = True
diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py
index f47277b4a..c3eb1b363 100644
--- a/lib/sqlalchemy/testing/fixtures.py
+++ b/lib/sqlalchemy/testing/fixtures.py
@@ -51,6 +51,13 @@ class TestBase(object):
assert val, msg
@config.fixture()
+ def connection_no_trans(self):
+ eng = getattr(self, "bind", None) or config.db
+
+ with eng.connect() as conn:
+ yield conn
+
+ @config.fixture()
def connection(self):
global _connection_fixture_connection
diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py
index de2b8f12c..208ba0091 100644
--- a/lib/sqlalchemy/testing/requirements.py
+++ b/lib/sqlalchemy/testing/requirements.py
@@ -18,6 +18,7 @@ to provide specific inclusion/exclusions.
import platform
import sys
+from sqlalchemy.pool.impl import QueuePool
from . import exclusions
from .. import util
@@ -117,6 +118,15 @@ class SuiteRequirements(Requirements):
)
@property
+ def queue_pool(self):
+ """target database is using QueuePool"""
+
+ def go(config):
+ return isinstance(config.db.pool, QueuePool)
+
+ return exclusions.only_if(go)
+
+ @property
def self_referential_foreign_keys(self):
"""Target database must support self-referential foreign keys."""
diff --git a/lib/sqlalchemy/testing/suite/test_dialect.py b/lib/sqlalchemy/testing/suite/test_dialect.py
index a236b1076..c2c17d0dd 100644
--- a/lib/sqlalchemy/testing/suite/test_dialect.py
+++ b/lib/sqlalchemy/testing/suite/test_dialect.py
@@ -180,8 +180,8 @@ class AutocommitIsolationTest(fixtures.TablesTest):
with conn.begin():
conn.execute(self.tables.some_table.delete())
- def test_autocommit_on(self):
- conn = config.db.connect()
+ def test_autocommit_on(self, connection_no_trans):
+ conn = connection_no_trans
c2 = conn.execution_options(isolation_level="AUTOCOMMIT")
self._test_conn_autocommits(c2, True)
@@ -189,12 +189,14 @@ class AutocommitIsolationTest(fixtures.TablesTest):
self._test_conn_autocommits(conn, False)
- def test_autocommit_off(self):
- conn = config.db.connect()
+ def test_autocommit_off(self, connection_no_trans):
+ conn = connection_no_trans
self._test_conn_autocommits(conn, False)
- def test_turn_autocommit_off_via_default_iso_level(self):
- conn = config.db.connect()
+ def test_turn_autocommit_off_via_default_iso_level(
+ self, connection_no_trans
+ ):
+ conn = connection_no_trans
conn = conn.execution_options(isolation_level="AUTOCOMMIT")
self._test_conn_autocommits(conn, True)
diff --git a/lib/sqlalchemy/testing/suite/test_results.py b/lib/sqlalchemy/testing/suite/test_results.py
index e8dd6cf2c..6c2880ad4 100644
--- a/lib/sqlalchemy/testing/suite/test_results.py
+++ b/lib/sqlalchemy/testing/suite/test_results.py
@@ -227,6 +227,8 @@ class ServerSideCursorsTest(
__backend__ = True
def _is_server_side(self, cursor):
+ # TODO: this is a huge issue as it prevents these tests from being
+ # usable by third party dialects.
if self.engine.dialect.driver == "psycopg2":
return bool(cursor.name)
elif self.engine.dialect.driver == "pymysql":
@@ -239,7 +241,7 @@ class ServerSideCursorsTest(
return isinstance(cursor, sscursor)
elif self.engine.dialect.driver == "mariadbconnector":
return not cursor.buffered
- elif self.engine.dialect.driver == "asyncpg":
+ elif self.engine.dialect.driver in ("asyncpg", "aiosqlite"):
return cursor.server_side
else:
return False
@@ -279,7 +281,14 @@ class ServerSideCursorsTest(
False,
),
("for_update_expr", True, select(1).with_for_update(), True),
- ("for_update_string", True, "SELECT 1 FOR UPDATE", True),
+ # TODO: need a real requirement for this, or dont use this test
+ (
+ "for_update_string",
+ True,
+ "SELECT 1 FOR UPDATE",
+ True,
+ testing.skip_if("sqlite"),
+ ),
("text_no_ss", False, text("select 42"), False),
(
"text_ss_option",