|
1 | 1 | import contextlib |
| 2 | +import sys |
2 | 3 | import unittest |
3 | 4 | import unittest.mock |
4 | 5 |
|
|
13 | 14 | from .utils import IsolatedTrioTestCase |
14 | 15 |
|
15 | 16 |
|
| 17 | +if sys.version_info[:2] < (3, 11): # pragma: no cover |
| 18 | + from exceptiongroup import ExceptionGroup |
| 19 | + |
| 20 | + |
16 | 21 | class AssemblerTests(IsolatedTrioTestCase): |
17 | 22 | def setUp(self): |
18 | 23 | self.pause = unittest.mock.Mock() |
@@ -508,31 +513,35 @@ async def test_close_is_idempotent(self): |
508 | 513 |
|
509 | 514 | async def test_get_fails_when_get_is_running(self): |
510 | 515 | """get cannot be called concurrently.""" |
511 | | - with trio.testing.RaisesGroup(ConcurrencyError): |
| 516 | + with self.assertRaises(ExceptionGroup) as raised: |
512 | 517 | async with trio.open_nursery() as nursery: |
513 | 518 | nursery.start_soon(self.assembler.get) |
514 | 519 | nursery.start_soon(self.assembler.get) |
| 520 | + self.assertIsInstance(raised.exception.exceptions[0], ConcurrencyError) |
515 | 521 |
|
516 | 522 | async def test_get_fails_when_get_iter_is_running(self): |
517 | 523 | """get cannot be called concurrently with get_iter.""" |
518 | | - with trio.testing.RaisesGroup(ConcurrencyError): |
| 524 | + with self.assertRaises(ExceptionGroup) as raised: |
519 | 525 | async with trio.open_nursery() as nursery: |
520 | 526 | nursery.start_soon(lambda: alist(self.assembler.get_iter())) |
521 | 527 | nursery.start_soon(self.assembler.get) |
| 528 | + self.assertIsInstance(raised.exception.exceptions[0], ConcurrencyError) |
522 | 529 |
|
523 | 530 | async def test_get_iter_fails_when_get_is_running(self): |
524 | 531 | """get_iter cannot be called concurrently with get.""" |
525 | | - with trio.testing.RaisesGroup(ConcurrencyError): |
| 532 | + with self.assertRaises(ExceptionGroup) as raised: |
526 | 533 | async with trio.open_nursery() as nursery: |
527 | 534 | nursery.start_soon(self.assembler.get) |
528 | 535 | nursery.start_soon(lambda: alist(self.assembler.get_iter())) |
| 536 | + self.assertIsInstance(raised.exception.exceptions[0], ConcurrencyError) |
529 | 537 |
|
530 | 538 | async def test_get_iter_fails_when_get_iter_is_running(self): |
531 | 539 | """get_iter cannot be called concurrently.""" |
532 | | - with trio.testing.RaisesGroup(ConcurrencyError): |
| 540 | + with self.assertRaises(ExceptionGroup) as raised: |
533 | 541 | async with trio.open_nursery() as nursery: |
534 | 542 | nursery.start_soon(lambda: alist(self.assembler.get_iter())) |
535 | 543 | nursery.start_soon(lambda: alist(self.assembler.get_iter())) |
| 544 | + self.assertIsInstance(raised.exception.exceptions[0], ConcurrencyError) |
536 | 545 |
|
537 | 546 | # Test setting limits. |
538 | 547 |
|
|
0 commit comments