API refactor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-07 16:25:52 +09:00
parent 76d0d86211
commit 91c7e04474
1171 changed files with 81940 additions and 44117 deletions

View File

@@ -1,5 +1,5 @@
# testing/engines.py
# Copyright (C) 2005-2023 the SQLAlchemy authors and contributors
# Copyright (C) 2005-2025 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
@@ -289,8 +289,7 @@ def testing_engine(
options: Optional[Dict[str, Any]] = None,
asyncio: Literal[False] = False,
transfer_staticpool: bool = False,
) -> Engine:
...
) -> Engine: ...
@typing.overload
@@ -299,8 +298,7 @@ def testing_engine(
options: Optional[Dict[str, Any]] = None,
asyncio: Literal[True] = True,
transfer_staticpool: bool = False,
) -> AsyncEngine:
...
) -> AsyncEngine: ...
def testing_engine(
@@ -332,16 +330,18 @@ def testing_engine(
url = url or config.db.url
url = make_url(url)
if options is None:
if config.db is None or url.drivername == config.db.url.drivername:
options = config.db_opts
else:
options = {}
elif config.db is not None and url.drivername == config.db.url.drivername:
default_opt = config.db_opts.copy()
default_opt.update(options)
engine = create_engine(url, **options)
if (
config.db is None or url.drivername == config.db.url.drivername
) and config.db_opts:
use_options = config.db_opts.copy()
else:
use_options = {}
if options is not None:
use_options.update(options)
engine = create_engine(url, **use_options)
if sqlite_savepoint and engine.name == "sqlite":
# apply SQLite savepoint workaround
@@ -370,7 +370,12 @@ def testing_engine(
True # enable event blocks, helps with profiling
)
if isinstance(engine.pool, pool.QueuePool):
if (
isinstance(engine.pool, pool.QueuePool)
and "pool" not in use_options
and "pool_timeout" not in use_options
and "max_overflow" not in use_options
):
engine.pool._timeout = 0
engine.pool._max_overflow = 0
if use_reaper: