From d53e3e1dfaaef47d6547998f17762f6a251ba0c4 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Mon, 6 Nov 2023 22:39:02 +0100 Subject: [PATCH] Do not assume that greenlet is installed Update test to take into consideration the case where greenlet is not installed. This is to support sqlalchemy 2.1 that removes it as required dependency Change-Id: I50dddf76536169df8abfd70fbb9133f2b13eec3d --- alembic/testing/requirements.py | 12 ++++++++++++ tests/test_op.py | 2 +- tox.ini | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/alembic/testing/requirements.py b/alembic/testing/requirements.py index 2107da46..6e07e28e 100644 --- a/alembic/testing/requirements.py +++ b/alembic/testing/requirements.py @@ -95,6 +95,18 @@ class SuiteRequirements(Requirements): "SQLAlchemy 2.x test", ) + @property + def asyncio(self): + def go(config): + try: + import greenlet # noqa: F401 + except ImportError: + return False + else: + return True + + return self.sqlalchemy_14 + exclusions.only_if(go) + @property def comments(self): return exclusions.only_if( diff --git a/tests/test_op.py b/tests/test_op.py index f1b8d27d..2b924d28 100644 --- a/tests/test_op.py +++ b/tests/test_op.py @@ -1267,7 +1267,7 @@ class OpTest(TestBase): ): op.run_async(go) - @config.requirements.sqlalchemy_14 + @config.requirements.asyncio def test_run_async_ok(self): from sqlalchemy.ext.asyncio import AsyncConnection diff --git a/tox.ini b/tox.ini index 62ef921a..24219bb4 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,8 @@ deps=pytest>4.6 mako python-dateutil zimports - black==22.3.0 + black==23.3.0 + greenlet>=1 -- 2.47.2