Skip to content

Commit

Permalink
tests: move to pytest-lazy-fixtures dep & mqtt update
Browse files Browse the repository at this point in the history
This PR addresses failing tests due to pytest-lazy-fixture incompatibility with pytest v8, and breaking changes in paho.mqtt v2.

Replaces pytest-lazy-fixture with pytest-lazy-fixtures, and adjusts use of mqtt client to conform to new api.
  • Loading branch information
peterschutt committed Feb 16, 2024
1 parent 8d26ee5 commit ef6acb8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ test = [
"pymongo >= 4",
"pymysql[rsa]",
"PySide6 >= 6.6; python_implementation == 'CPython'",
"pytest ~= 7.4",
"pytest-lazy-fixture",
"pytest >= 7.4.0",
"pytest-lazy-fixtures",
"pytest-mock",
"time-machine >= 2.13.0; python_implementation == 'CPython'",
"uwsgi; python_implementation == 'CPython' and platform_system == 'Linux'",
Expand Down
29 changes: 15 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import pytest
from _pytest.fixtures import SubRequest
from pytest_lazyfixture import lazy_fixture
from pytest_lazy_fixtures import lf

from apscheduler.abc import DataStore, EventBroker, Serializer
from apscheduler.datastores.memory import MemoryDataStore
Expand Down Expand Up @@ -68,11 +68,12 @@ async def redis_broker(serializer: Serializer) -> EventBroker:

@pytest.fixture
def mqtt_broker(serializer: Serializer) -> EventBroker:
from paho.mqtt.enums import CallbackAPIVersion
from paho.mqtt.client import Client

from apscheduler.eventbrokers.mqtt import MQTTEventBroker

return MQTTEventBroker(Client(), serializer=serializer)
return MQTTEventBroker(Client(CallbackAPIVersion.VERSION1), serializer=serializer)


@pytest.fixture
Expand All @@ -88,19 +89,19 @@ async def asyncpg_broker(serializer: Serializer) -> EventBroker:

@pytest.fixture(
params=[
pytest.param(lazy_fixture("local_broker"), id="local"),
pytest.param(lf("local_broker"), id="local"),
pytest.param(
lazy_fixture("asyncpg_broker"),
lf("asyncpg_broker"),
id="asyncpg",
marks=[pytest.mark.external_service],
),
pytest.param(
lazy_fixture("redis_broker"),
lf("redis_broker"),
id="redis",
marks=[pytest.mark.external_service],
),
pytest.param(
lazy_fixture("mqtt_broker"), id="mqtt", marks=[pytest.mark.external_service]
lf("mqtt_broker"), id="mqtt", marks=[pytest.mark.external_service]
),
]
)
Expand Down Expand Up @@ -255,40 +256,40 @@ async def asyncmy_store() -> AsyncGenerator[DataStore, None]:
@pytest.fixture(
params=[
pytest.param(
lazy_fixture("memory_store"),
lf("memory_store"),
id="memory",
),
pytest.param(
lazy_fixture("aiosqlite_store"),
lf("aiosqlite_store"),
id="aiosqlite",
),
pytest.param(
lazy_fixture("asyncpg_store"),
lf("asyncpg_store"),
id="asyncpg",
marks=[pytest.mark.external_service],
),
pytest.param(
lazy_fixture("asyncmy_store"),
lf("asyncmy_store"),
id="asyncmy",
marks=[pytest.mark.external_service],
),
pytest.param(
lazy_fixture("psycopg_async_store"),
lf("psycopg_async_store"),
id="psycopg_async",
marks=[pytest.mark.external_service],
),
pytest.param(
lazy_fixture("psycopg_sync_store"),
lf("psycopg_sync_store"),
id="psycopg_sync",
marks=[pytest.mark.external_service],
),
pytest.param(
lazy_fixture("pymysql_store"),
lf("pymysql_store"),
id="pymysql",
marks=[pytest.mark.external_service],
),
pytest.param(
lazy_fixture("mongodb_store"),
lf("mongodb_store"),
id="mongodb",
marks=[pytest.mark.external_service],
),
Expand Down

0 comments on commit ef6acb8

Please sign in to comment.