From cc82b8367cb942222a4184dbd36cf2496efe66b7 Mon Sep 17 00:00:00 2001
From: Dmitry Pytaylo <dpytaylo@gmail.com>
Date: Sat, 2 Aug 2025 12:44:45 +0300
Subject: [PATCH] fix some test fails with trio

---
 tests/test_manager.py | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/tests/test_manager.py b/tests/test_manager.py
index e2f5d93..0d137d3 100644
--- a/tests/test_manager.py
+++ b/tests/test_manager.py
@@ -83,7 +83,11 @@ async def _send(message: Message) -> None:
     with contextlib.ExitStack() as stack:
         # Set up expected raised exceptions.
         if startup_exception is not None:
-            stack.enter_context(pytest.raises(startup_exception))
+            stack.enter_context(
+                pytest.raises(
+                    ExceptionGroup if concurrency == "trio" else startup_exception
+                )
+            )
         elif body_exception is not None:
             if shutdown_exception is not None:
                 # Trio now raises the new `ExceptionGroup` in case
@@ -94,9 +98,17 @@ async def _send(message: Message) -> None:
                     )
                 )
             else:
-                stack.enter_context(pytest.raises(body_exception))
+                stack.enter_context(
+                    pytest.raises(
+                        ExceptionGroup if concurrency == "trio" else body_exception
+                    )
+                )
         elif shutdown_exception is not None:
-            stack.enter_context(pytest.raises(shutdown_exception))
+            stack.enter_context(
+                pytest.raises(
+                    ExceptionGroup if concurrency == "trio" else shutdown_exception
+                )
+            )
 
         async with LifespanManager(app):
             # NOTE: this block should not execute in case of startup exception.
@@ -241,7 +253,8 @@ async def get(request: Request) -> Response:
 
     async with LifespanManager(app) as manager:
         async with httpx.AsyncClient(
-            transport=httpx.ASGITransport(app=manager.app), base_url="http://example.org"
+            transport=httpx.ASGITransport(app=manager.app),
+            base_url="http://example.org",
         ) as client:
             response = await client.get("/get")
             assert response.status_code == 200
