Skip to content

Commit 395c738

Browse files
committed
refactor: _wrap_asyncgen_fixture forwards positional args from the original fixture function to the wrapper.
1 parent ba324ef commit 395c738

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

pytest_asyncio/plugin.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,21 +300,30 @@ def _perhaps_rebind_fixture_func(func: _T, instance: Any | None) -> _T:
300300
return func
301301

302302

303+
AsyncGenFixtureParams = ParamSpec("AsyncGenFixtureParams")
303304
AsyncGenFixtureYieldType = TypeVar("AsyncGenFixtureYieldType")
304305

305306

306307
def _wrap_asyncgen_fixture(
307-
fixture_function: Callable[..., AsyncGeneratorType[AsyncGenFixtureYieldType, Any]],
308-
) -> Callable[..., AsyncGenFixtureYieldType]:
308+
fixture_function: Callable[
309+
AsyncGenFixtureParams, AsyncGeneratorType[AsyncGenFixtureYieldType, Any]
310+
],
311+
) -> Callable[
312+
Concatenate[FixtureRequest, AsyncGenFixtureParams], AsyncGenFixtureYieldType
313+
]:
309314
@functools.wraps(fixture_function)
310-
def _asyncgen_fixture_wrapper(request: FixtureRequest, **kwargs: Any):
315+
def _asyncgen_fixture_wrapper(
316+
request: FixtureRequest,
317+
*args: AsyncGenFixtureParams.args,
318+
**kwargs: AsyncGenFixtureParams.kwargs,
319+
):
311320
func = _perhaps_rebind_fixture_func(fixture_function, request.instance)
312321
event_loop_fixture_id = _get_event_loop_fixture_id_for_async_fixture(
313322
request, func
314323
)
315324
event_loop = request.getfixturevalue(event_loop_fixture_id)
316325
kwargs.pop(event_loop_fixture_id, None)
317-
gen_obj = func(**_add_kwargs(func, kwargs, request))
326+
gen_obj = func(*args, **_add_kwargs(func, kwargs, request))
318327

319328
async def setup():
320329
res = await gen_obj.__anext__() # type: ignore[union-attr]

0 commit comments

Comments
 (0)