Skip to content

Commit ed732d3

Browse files
committed
Remove use of MultiError
1 parent cbd6197 commit ed732d3

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

newsfragments/128.misc.rst

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Trio 0.22.0 deprecated ``MultiError`` in favor of the standard-library
2+
(or `backported <https://pypi.org/project/exceptiongroup/>`__) ``ExceptionGroup``
3+
type; ``pytest-trio`` now uses ``ExceptionGroup`` and therefore requires
4+
Trio 0.22.0 or later.

pytest_trio/_tests/test_async_yield_fixture.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,6 @@ def test_after():
300300
result = testdir.runpytest()
301301

302302
result.assert_outcomes(failed=1, passed=2)
303-
result.stdout.re_match_lines([r"E\W+RuntimeError: Crash during fixture teardown"])
303+
result.stdout.re_match_lines(
304+
[r"(E\W+| +\| )RuntimeError: Crash during fixture teardown"]
305+
)

pytest_trio/_tests/test_sync_fixture.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,6 @@ def test_after():
139139
result = testdir.runpytest()
140140

141141
result.assert_outcomes(failed=1, passed=2)
142-
result.stdout.re_match_lines([r"E\W+RuntimeError: Crash during fixture teardown"])
142+
result.stdout.re_match_lines(
143+
[r"(E\W+| +\| )RuntimeError: Crash during fixture teardown"]
144+
)

pytest_trio/plugin.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""pytest-trio implementation."""
2+
import sys
23
from functools import wraps, partial
3-
from traceback import format_exception
44
from collections.abc import Coroutine, Generator
55
from contextlib import asynccontextmanager
66
from inspect import isasyncgen, isasyncgenfunction, iscoroutinefunction
@@ -11,6 +11,9 @@
1111
from trio.abc import Clock, Instrument
1212
from trio.testing import MockClock
1313

14+
if sys.version_info[:2] < (3, 11):
15+
from exceptiongroup import BaseExceptionGroup
16+
1417
################################################################
1518
# Basic setup
1619
################################################################
@@ -52,13 +55,6 @@ def pytest_configure(config):
5255
)
5356

5457

55-
@pytest.hookimpl(tryfirst=True)
56-
def pytest_exception_interact(node, call, report):
57-
if issubclass(call.excinfo.type, trio.MultiError):
58-
# TODO: not really elegant (pytest cannot output color with this hack)
59-
report.longrepr = "".join(format_exception(*call.excinfo._excinfo))
60-
61-
6258
################################################################
6359
# Core support for trio fixtures and trio tests
6460
################################################################
@@ -407,8 +403,12 @@ async def _bootstrap_fixtures_and_run_test(**kwargs):
407403
)
408404
)
409405

410-
if test_ctx.error_list:
411-
raise trio.MultiError(test_ctx.error_list)
406+
if len(test_ctx.error_list) == 1:
407+
raise test_ctx.error_list[0]
408+
elif test_ctx.error_list:
409+
raise BaseExceptionGroup(
410+
"errors in async test and trio fixtures", test_ctx.error_list
411+
)
412412

413413
_bootstrap_fixtures_and_run_test._trio_test_runner_wrapped = True
414414
return _bootstrap_fixtures_and_run_test

0 commit comments

Comments
 (0)