Skip to content

Commit 3ba4165

Browse files
committed
Stop using deprecated trio.testing.RaisesGroup.
See python-trio/trio#3326. Apparently Trio maintainers didn't consider the possibility that others wouldn't be using pytest nor want to add it as a dependency just for to get this testing utility.
1 parent 058b6ae commit 3ba4165

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tests/trio/test_messages.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import contextlib
2+
import sys
23
import unittest
34
import unittest.mock
45

@@ -13,6 +14,10 @@
1314
from .utils import IsolatedTrioTestCase
1415

1516

17+
if sys.version_info[:2] < (3, 11): # pragma: no cover
18+
from exceptiongroup import ExceptionGroup
19+
20+
1621
class AssemblerTests(IsolatedTrioTestCase):
1722
def setUp(self):
1823
self.pause = unittest.mock.Mock()
@@ -508,31 +513,35 @@ async def test_close_is_idempotent(self):
508513

509514
async def test_get_fails_when_get_is_running(self):
510515
"""get cannot be called concurrently."""
511-
with trio.testing.RaisesGroup(ConcurrencyError):
516+
with self.assertRaises(ExceptionGroup) as raised:
512517
async with trio.open_nursery() as nursery:
513518
nursery.start_soon(self.assembler.get)
514519
nursery.start_soon(self.assembler.get)
520+
self.assertIsInstance(raised.exception.exceptions[0], ConcurrencyError)
515521

516522
async def test_get_fails_when_get_iter_is_running(self):
517523
"""get cannot be called concurrently with get_iter."""
518-
with trio.testing.RaisesGroup(ConcurrencyError):
524+
with self.assertRaises(ExceptionGroup) as raised:
519525
async with trio.open_nursery() as nursery:
520526
nursery.start_soon(lambda: alist(self.assembler.get_iter()))
521527
nursery.start_soon(self.assembler.get)
528+
self.assertIsInstance(raised.exception.exceptions[0], ConcurrencyError)
522529

523530
async def test_get_iter_fails_when_get_is_running(self):
524531
"""get_iter cannot be called concurrently with get."""
525-
with trio.testing.RaisesGroup(ConcurrencyError):
532+
with self.assertRaises(ExceptionGroup) as raised:
526533
async with trio.open_nursery() as nursery:
527534
nursery.start_soon(self.assembler.get)
528535
nursery.start_soon(lambda: alist(self.assembler.get_iter()))
536+
self.assertIsInstance(raised.exception.exceptions[0], ConcurrencyError)
529537

530538
async def test_get_iter_fails_when_get_iter_is_running(self):
531539
"""get_iter cannot be called concurrently."""
532-
with trio.testing.RaisesGroup(ConcurrencyError):
540+
with self.assertRaises(ExceptionGroup) as raised:
533541
async with trio.open_nursery() as nursery:
534542
nursery.start_soon(lambda: alist(self.assembler.get_iter()))
535543
nursery.start_soon(lambda: alist(self.assembler.get_iter()))
544+
self.assertIsInstance(raised.exception.exceptions[0], ConcurrencyError)
536545

537546
# Test setting limits.
538547

0 commit comments

Comments
 (0)