summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2022-09-22 01:00:16 +0300
committerAlex Grönholm <alex.gronholm@nextday.fi>2022-09-22 01:00:16 +0300
commitb3c6bca584db5658dfcae8ad02ab39aa07fb9cbc (patch)
treef43422a87ed5f61e40186d3e0ec2ee188820bb56
parent40cf1621c6574cdbff9aaffa7b6ae83e1bf349d9 (diff)
downloadapscheduler-b3c6bca584db5658dfcae8ad02ab39aa07fb9cbc.tar.gz
Fixed the test suite on PyPy
-rw-r--r--.github/workflows/test.yml2
-rw-r--r--pyproject.toml18
-rw-r--r--tests/conftest.py11
3 files changed, 23 insertions, 8 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 94b8031..4e05b1f 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- python-version: ["3.7", "3.10", "3.11-dev"]
+ python-version: ["3.7", "3.10", "3.11-dev", "pypy-3.9"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
diff --git a/pyproject.toml b/pyproject.toml
index a45f573..ef794e8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -41,16 +41,19 @@ cbor = ["cbor2 >= 5.0"]
mongodb = ["pymongo >= 4"]
mqtt = ["paho-mqtt >= 1.5"]
redis = ["redis >= 4.0"]
-sqlalchemy = ["sqlalchemy >= 1.4.22"]
+sqlalchemy = [
+ "sqlalchemy >= 1.4.22",
+ "greenlet >= 2.0.0a2; python_version >= '3.11'"
+]
test = [
- "asyncpg >= 0.20",
- "asyncmy >= 0.2.5",
- "cbor2 >= 5.0",
+ "APScheduler[cbor,mongodb,mqtt,redis,sqlalchemy]",
+ "APScheduler[asyncpg]; python_implementation == 'CPython'",
+ "asyncmy >= 0.2.5; python_implementation == 'CPython'",
"coverage",
"freezegun",
- "greenlet >= 2.0.0a2; python_version >= '3.11'",
"paho-mqtt >= 1.5",
- "psycopg2",
+ "psycopg2; python_implementation == 'CPython'",
+ "psycopg2cffi; python_implementation != 'CPython'",
"pymongo >= 4",
"pymysql[rsa]",
"pytest >= 5.0",
@@ -110,6 +113,9 @@ isolated_build = true
extras = test
commands = coverage run -m pytest {posargs}
+[testenv:pypy3]
+commands = pytest {posargs}
+
[testenv:pyright]
deps = pyright
commands = pyright --verifytypes apscheduler
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