Skip to content

Commit

Permalink
test: Replace dependency pytest-lazy-fixture (litestar-org#3291)
Browse files Browse the repository at this point in the history
A new release of the pytest-lazy-fixture has not been published since
February 2020 (v0.6.3) and it is not compatible with recent pytest
versions, starting from v8.0.0 (I think).

Replace it with pytest-lazy-fixtures (note the 's' at the end) which is
actively maintained, see:

  https://github.com/dev-petrov/pytest-lazy-fixtures
  • Loading branch information
carlsmedstad authored Mar 30, 2024
1 parent 81475c6 commit 26cbe7a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 29 deletions.
27 changes: 9 additions & 18 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ linting = [
"pyright==1.1.344",
"asyncpg-stubs",
"types-beautifulsoup4",
"types-pytest-lazy-fixture",
"types-python-jose",
"types-pyyaml",
"types-redis",
Expand All @@ -161,7 +160,7 @@ test = [
"pytest<8.0.0",
"pytest-asyncio",
"pytest-cov",
"pytest-lazy-fixture",
"pytest-lazy-fixtures",
"pytest-mock",
"pytest-rerunfailures",
"pytest-timeout",
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from unittest.mock import AsyncMock, MagicMock

import pytest
from pytest_lazyfixture import lazy_fixture
from pytest_lazy_fixtures import lf
from redis.asyncio import Redis as AsyncRedis
from redis.client import Redis
from time_machine import travel
Expand Down Expand Up @@ -109,8 +109,8 @@ def cookie_session_backend(cookie_session_backend_config: CookieBackendConfig) -

@pytest.fixture(
params=[
pytest.param(lazy_fixture("cookie_session_backend_config"), id="cookie"),
pytest.param(lazy_fixture("server_side_session_config"), id="server-side"),
pytest.param(lf("cookie_session_backend_config"), id="cookie"),
pytest.param(lf("server_side_session_config"), id="server-side"),
]
)
def session_backend_config(request: pytest.FixtureRequest) -> ServerSideSessionConfig | CookieBackendConfig:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import MagicMock

import pytest
from pytest_lazyfixture import lazy_fixture
from pytest_lazy_fixtures import lf

from litestar import Litestar, Request, get
from litestar.events.emitter import SimpleEventEmitter
Expand Down Expand Up @@ -36,7 +36,7 @@ async def listener_fn(*args: Any, **kwargs: Any) -> None:
return listener_fn


@pytest.mark.parametrize("event_listener", [lazy_fixture("sync_listener"), lazy_fixture("async_listener")])
@pytest.mark.parametrize("event_listener", [lf("sync_listener"), lf("async_listener")])
def test_event_listener(mock: MagicMock, event_listener: EventListener, anyio_backend: AnyIOBackend) -> None:
@get("/")
def route_handler(request: Request[Any, Any, Any]) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from unittest.mock import AsyncMock, MagicMock

import pytest
from pytest_lazyfixture import lazy_fixture
from pytest_lazy_fixtures import lf

from litestar import Controller, Litestar, Request, WebSocket
from litestar.datastructures import State
Expand Down Expand Up @@ -47,9 +47,9 @@ async def listener(data: str) -> str:
@pytest.mark.parametrize(
"listener",
[
lazy_fixture("sync_listener_callable"),
lazy_fixture("async_listener_callable"),
lazy_fixture("listener_class"),
lf("sync_listener_callable"),
lf("async_listener_callable"),
lf("listener_class"),
],
)
def test_basic_listener(mock: MagicMock, listener: Union[websocket_listener, Type[WebsocketListener]]) -> None:
Expand Down

0 comments on commit 26cbe7a

Please sign in to comment.