From b3c6bca584db5658dfcae8ad02ab39aa07fb9cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Thu, 22 Sep 2022 01:00:16 +0300 Subject: Fixed the test suite on PyPy --- tests/conftest.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/conftest.py b/tests/conftest.py index 0de4349..92e9d92 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,6 @@ from __future__ import annotations +import platform import sys from contextlib import AsyncExitStack from tempfile import TemporaryDirectory @@ -71,6 +72,7 @@ def mqtt_broker(serializer: Serializer) -> EventBroker: @pytest.fixture async def asyncpg_broker(serializer: Serializer) -> EventBroker: + pytest.importorskip("asyncpg", reason="asyncpg is not installed") from apscheduler.eventbrokers.asyncpg import AsyncpgEventBroker broker = AsyncpgEventBroker.from_dsn( @@ -146,7 +148,12 @@ def psycopg2_store() -> DataStore: from apscheduler.datastores.sqlalchemy import SQLAlchemyDataStore - engine = create_engine("postgresql+psycopg2://postgres:secret@localhost/testdb") + if platform.python_implementation() == "CPython": + dialect = "psycopg2" + else: + dialect = "psycopg2cffi" + + engine = create_engine(f"postgresql+{dialect}://postgres:secret@localhost/testdb") try: with engine.begin() as conn: conn.execute(text("CREATE SCHEMA IF NOT EXISTS psycopg2")) @@ -171,6 +178,7 @@ def pymysql_store() -> DataStore: @pytest.fixture async def asyncpg_store() -> DataStore: + pytest.importorskip("asyncpg", reason="asyncpg is not installed") from sqlalchemy.ext.asyncio import create_async_engine from apscheduler.datastores.sqlalchemy import SQLAlchemyDataStore @@ -186,6 +194,7 @@ async def asyncpg_store() -> DataStore: @pytest.fixture async def asyncmy_store() -> DataStore: + pytest.importorskip("asyncmy", reason="asyncmy is not installed") from sqlalchemy.ext.asyncio import create_async_engine from apscheduler.datastores.sqlalchemy import SQLAlchemyDataStore -- cgit v1.2.1