Skip to content

Commit

Permalink
2 tests also async, dont seem to pass on trio
Browse files Browse the repository at this point in the history
  • Loading branch information
euri10 committed Nov 29, 2024
1 parent a97e262 commit 8cf963a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/examples/testing/test_get_session_data_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ def set_session_data(request: Request) -> None:


@pytest.mark.anyio
async def test_set_session_data() -> None:
@pytest.mark.parametrize(
"anyio_backend",
[
pytest.param("asyncio"),
pytest.param("trio", marks=pytest.mark.xfail(reason="Known issue with trio backend", strict=False)),
],
)
async def test_set_session_data(anyio_backend: str) -> None:
async with AsyncTestClient(app=app, session_config=session_config) as client:
await client.post("/test")
assert await client.get_session_data() == {"foo": "bar"}
10 changes: 10 additions & 0 deletions docs/examples/testing/test_set_session_data_async.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Any, Dict

import pytest

from litestar import Litestar, Request, get
from litestar.middleware.session.server_side import ServerSideSessionConfig
from litestar.testing import AsyncTestClient
Expand All @@ -15,6 +17,14 @@ def get_session_data(request: Request) -> Dict[str, Any]:
app = Litestar(route_handlers=[get_session_data], middleware=[session_config.middleware], debug=True)


@pytest.mark.anyio
@pytest.mark.parametrize(
"anyio_backend",
[
pytest.param("asyncio"),
pytest.param("trio", marks=pytest.mark.xfail(reason="Known issue with trio backend", strict=False)),
],
)
async def test_get_session_data() -> None:
async with AsyncTestClient(app=app, session_config=session_config) as client:
await client.set_session_data({"foo": "bar"})
Expand Down

0 comments on commit 8cf963a

Please sign in to comment.