From 8cf963a53ba4c0fb3a59c2ae987d71ec6d752e78 Mon Sep 17 00:00:00 2001 From: euri10 Date: Fri, 29 Nov 2024 17:10:57 +0100 Subject: [PATCH] 2 tests also async, dont seem to pass on trio --- docs/examples/testing/test_get_session_data_async.py | 9 ++++++++- docs/examples/testing/test_set_session_data_async.py | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/examples/testing/test_get_session_data_async.py b/docs/examples/testing/test_get_session_data_async.py index 5d1c528f92..cb8cfdc151 100644 --- a/docs/examples/testing/test_get_session_data_async.py +++ b/docs/examples/testing/test_get_session_data_async.py @@ -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"} diff --git a/docs/examples/testing/test_set_session_data_async.py b/docs/examples/testing/test_set_session_data_async.py index 167f85095c..6dd61d8a80 100644 --- a/docs/examples/testing/test_set_session_data_async.py +++ b/docs/examples/testing/test_set_session_data_async.py @@ -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 @@ -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"})