Skip to content
Open
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions pytest_trio/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,15 @@ 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:
yield_outcome.send(func_value)
except StopIteration:
pass
else:
__tracebackhide__ = False
raise RuntimeError("too many yields in fixture")


Expand All @@ -327,13 +329,15 @@ 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}"
)
instruments = [i for i in kwargs.values() if isinstance(i, Instrument)]
try:
return run(partial(fn, **kwargs), clock=clock, instruments=instruments)
except BaseExceptionGroup as eg:
__tracebackhide__ = False
queue = [eg]
leaves = []
while queue:
Expand Down Expand Up @@ -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
)
Expand Down
Loading