From 76999c942ca82fb2e0238566fdf9c5405086fc1f Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Thu, 1 Oct 2026 20:53:34 -0600 Subject: [PATCH] Model SQLAlchemy 2.0 and 2.1 in the base-install test --- tests/fixtures/base_install_worker.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/fixtures/base_install_worker.py b/tests/fixtures/base_install_worker.py index 6ba0b36..d9d04a3 100644 --- a/tests/fixtures/base_install_worker.py +++ b/tests/fixtures/base_install_worker.py @@ -6,8 +6,15 @@ the ``instrumentation`` extra. Argument: a directory for the feedback database. """ import sys +from importlib.metadata import version -for _name in ("greenlet", "aiosqlite"): +# SQLAlchemy 2.1 refuses to import sqlalchemy.ext.asyncio without greenlet, +# once: a second import succeeds. 2.0 imports it and fails on first use. +# On 2.0 the module is blocked too, so both versions fail at import. +_blocked = ["greenlet", "aiosqlite"] +if tuple(int(p) for p in version("sqlalchemy").split(".")[:2]) < (2, 1): + _blocked.append("sqlalchemy.ext.asyncio") +for _name in _blocked: sys.modules[_name] = None # import raises ModuleNotFoundError import asyncio # noqa: E402