Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5be7c99
chore: deprecate `RaisesGroup`
AbduazizZiyodov Sep 23, 2025
adae0e3
feat: deprecate `RaisesGroup` using `deprecate_attributes` utility
AbduazizZiyodov Dec 25, 2025
cf590c0
feat: deprecate `Matcher`
AbduazizZiyodov Dec 25, 2025
cc2e35a
feat: make `DeprecatedAttribute` as `final`
AbduazizZiyodov Dec 25, 2025
1b0fa93
feat: supress warnings about deprecation warning on specific test cases
AbduazizZiyodov Dec 25, 2025
f0db1ff
fix: replace RaisesGroup & Matcher with pytest alternatives across al…
AbduazizZiyodov Dec 25, 2025
70b2bc3
Merge branch 'main' into deprecate-raises-group
AbduazizZiyodov Dec 25, 2025
84af490
docs: add newsfragment
AbduazizZiyodov Dec 25, 2025
f05dbf9
fix: change version number
AbduazizZiyodov Dec 25, 2025
82ba96a
style: format merged code
AbduazizZiyodov Dec 25, 2025
03b0e35
fix: adjust `test_static_tool_sees_class_members` for deprecated clas…
AbduazizZiyodov Dec 26, 2025
326d819
fix: change text formatting, so that build tool won't search for refe…
AbduazizZiyodov Dec 26, 2025
54ef274
fix: add underscore prefix on class names to match exported classes' …
AbduazizZiyodov Dec 26, 2025
f71713a
style: correct formatting on newsfragment
AbduazizZiyodov Dec 26, 2025
bda1477
fix: find/replace
AbduazizZiyodov Dec 26, 2025
7544b8a
fix: use `pytest.deprecated_call` context manager
AbduazizZiyodov Dec 26, 2025
4ff73e7
fix: delete type tests, mypy errors
AbduazizZiyodov Dec 27, 2025
75b76f3
fix: remove deprecated calls
AbduazizZiyodov Dec 27, 2025
ba44d3c
chore: update `_check_type_completeness.json`
AbduazizZiyodov Dec 27, 2025
4a97684
test: add test case to test deprecation
AbduazizZiyodov Dec 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/3326.deprecated.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Both :class:`trio.testing.RaisesGroup` and :class:`trio.testing.Matcher` have been deprecated. Pytest alternatives ``pytest.RaisesGroup`` and ``pytest.RaisesExc`` (respectively) are considered correct replacement.
12 changes: 6 additions & 6 deletions src/trio/_core/_tests/test_cancelled.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import trio
from trio import Cancelled
from trio.lowlevel import current_task
from trio.testing import RaisesGroup, wait_all_tasks_blocked
from trio.testing import wait_all_tasks_blocked

from .test_ki import ki_self

Expand Down Expand Up @@ -108,7 +108,7 @@ async def failing_task(task_status: trio.TaskStatus[trio.lowlevel.Task]) -> None
task_status.started(current_task())
raise ValueError

with RaisesGroup(ValueError, TypeError):
with pytest.RaisesGroup(ValueError, TypeError):
async with trio.open_nursery() as nursery:
fail_task = await nursery.start(failing_task)
with pytest.raises(Cancelled, match=match_str.format(fail_task)):
Expand All @@ -123,7 +123,7 @@ async def failing_task(task_status: trio.TaskStatus[trio.lowlevel.Task]) -> None
await wait_all_tasks_blocked()
raise ValueError

with RaisesGroup(ValueError, TypeError):
with pytest.RaisesGroup(ValueError, TypeError):
async with trio.open_nursery() as nursery:
fail_task = await nursery.start(failing_task)
await nursery.start(cancelled_task, fail_task)
Expand All @@ -147,7 +147,7 @@ async def cancelled_task() -> None:
):
await trio.sleep_forever()

with RaisesGroup(ValueError):
with pytest.RaisesGroup(ValueError):
async with trio.open_nursery() as nursery:
nursery.start_soon(cancelled_task)
await wait_all_tasks_blocked()
Expand Down Expand Up @@ -192,7 +192,7 @@ async def child() -> None:
):
await trio.sleep_forever()

with RaisesGroup(ValueError):
with pytest.RaisesGroup(ValueError):
async with trio.open_nursery() as nursery:
nursery.start_soon(child)
await ev.wait()
Expand All @@ -214,7 +214,7 @@ async def sleeper(name: str) -> None:
async def raiser(name: str) -> None:
ki_self()

with RaisesGroup(KeyboardInterrupt):
with pytest.RaisesGroup(KeyboardInterrupt):
async with trio.open_nursery() as nursery:
nursery.start_soon(sleeper, "s1")
nursery.start_soon(sleeper, "s2")
Expand Down
6 changes: 2 additions & 4 deletions src/trio/_core/_tests/test_ki.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import outcome
import pytest

from trio.testing import RaisesGroup

from .tutil import gc_collect_harder

try:
Expand Down Expand Up @@ -309,7 +307,7 @@ async def check_unprotected_kill() -> None:
nursery.start_soon(raiser, "r1", record_set)

# raises inside a nursery, so the KeyboardInterrupt is wrapped in an ExceptionGroup
with RaisesGroup(KeyboardInterrupt):
with pytest.RaisesGroup(KeyboardInterrupt):
_core.run(check_unprotected_kill)
assert record_set == {"s1 ok", "s2 ok", "r1 raise ok"}

Expand All @@ -326,7 +324,7 @@ async def check_protected_kill() -> None:
# __aexit__ blocks, and then receives the KI

# raises inside a nursery, so the KeyboardInterrupt is wrapped in an ExceptionGroup
with RaisesGroup(KeyboardInterrupt):
with pytest.RaisesGroup(KeyboardInterrupt):
_core.run(check_protected_kill)
assert record_set == {"s1 ok", "s2 ok", "r1 cancel ok"}

Expand Down
9 changes: 4 additions & 5 deletions src/trio/_core/_tests/test_parking_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
current_task,
remove_parking_lot_breaker,
)
from trio.testing import Matcher, RaisesGroup

from ... import _core
from ...testing import wait_all_tasks_blocked
Expand Down Expand Up @@ -267,8 +266,8 @@ async def bad_parker(lot: ParkingLot, scope: _core.CancelScope) -> None:
cs = _core.CancelScope()

# check that parked task errors
with RaisesGroup(
Matcher(_core.BrokenResourceError, match="^Parking lot broken by"),
with pytest.RaisesGroup(
pytest.RaisesExc(_core.BrokenResourceError, match="^Parking lot broken by"),
):
async with _core.open_nursery() as nursery:
nursery.start_soon(bad_parker, lot, cs)
Expand Down Expand Up @@ -382,8 +381,8 @@ async def return_me_and_park(
await lot.park()

lot = ParkingLot()
with RaisesGroup(
Matcher(_core.BrokenResourceError, match="^Parking lot broken by"),
with pytest.RaisesGroup(
pytest.RaisesExc(_core.BrokenResourceError, match="^Parking lot broken by"),
):
async with _core.open_nursery() as nursery:
child_task = await nursery.start(return_me_and_park, lot)
Expand Down
Loading