From 9001e2c2534218f3a24f3d855e221b9974171b6b Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 15 Sep 2025 00:12:10 +0100 Subject: [PATCH] Fix test failures with pytest 8.4 https://github.com/pytest-dev/pytest/pull/13380 (I think) means that pytest now fails if all the traceback frames after the cut have `__tracebackhide__ = True` set. To avoid this, set `__tracebackhide__ = False` if we're about to raise an exception directly from the plugin. Fixes: #151 --- pytest_trio/plugin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pytest_trio/plugin.py b/pytest_trio/plugin.py index ebfcbee..1da8015 100644 --- a/pytest_trio/plugin.py +++ b/pytest_trio/plugin.py @@ -297,6 +297,7 @@ async def run(self, test_ctx, contextvars_ctx): except StopAsyncIteration: pass else: + __tracebackhide__ = False raise RuntimeError("too many yields in fixture") elif isinstance(func_value, Generator): try: @@ -304,6 +305,7 @@ async def run(self, test_ctx, contextvars_ctx): except StopIteration: pass else: + __tracebackhide__ = False raise RuntimeError("too many yields in fixture") @@ -327,6 +329,7 @@ def wrapper(**kwargs): elif len(clocks) == 1: clock = list(clocks.values())[0] else: + __tracebackhide__ = False raise ValueError( f"Expected at most one Clock in kwargs, got {clocks!r}" ) @@ -334,6 +337,7 @@ def wrapper(**kwargs): try: return run(partial(fn, **kwargs), clock=clock, instruments=instruments) except BaseExceptionGroup as eg: + __tracebackhide__ = False queue = [eg] leaves = [] while queue: @@ -410,8 +414,10 @@ async def _bootstrap_fixtures_and_run_test(**kwargs): ) if len(test_ctx.error_list) == 1: + __tracebackhide__ = False raise test_ctx.error_list[0] elif test_ctx.error_list: + __tracebackhide__ = False raise BaseExceptionGroup( "errors in async test and trio fixtures", test_ctx.error_list )