Forwarded: https://github.com/agronholm/anyio/pull/1063

--- a/tests/test_taskgroups.py
+++ b/tests/test_taskgroups.py
@@ -11,7 +11,6 @@
 from unittest import mock
 
 import pytest
-from exceptiongroup import catch
 from pytest import FixtureRequest, MonkeyPatch
 
 import anyio
@@ -1555,8 +1554,10 @@
 
     with CancelScope() as scope:
         scope.cancel()
-        with catch({get_cancelled_exc_class(): handler}):
+        try:
             await anyio.sleep_forever()
+        except get_cancelled_exc_class() as e:
+            handler(BaseExceptionGroup("", [e]))
 
 
 async def test_cancel_child_task_when_host_is_shielded() -> None:
