Skip to content

Commit d05365b

Browse files
committed
refactor: _wrap_async_fixture returns a Callable rather than modifying the FixtureDef
1 parent 3591c24 commit d05365b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pytest_asyncio/plugin.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def _synchronize_async_fixture(fixturedef: FixtureDef) -> None:
268268
if inspect.isasyncgenfunction(fixturedef.func):
269269
_wrap_asyncgen_fixture(fixturedef)
270270
elif inspect.iscoroutinefunction(fixturedef.func):
271-
_wrap_async_fixture(fixturedef)
271+
fixturedef.func = _wrap_async_fixture(fixturedef) # type: ignore[misc]
272272

273273

274274
def _add_kwargs(
@@ -346,12 +346,12 @@ async def async_finalizer() -> None:
346346
fixturedef.func = _asyncgen_fixture_wrapper # type: ignore[misc]
347347

348348

349-
def _wrap_async_fixture(fixturedef: FixtureDef) -> None:
350-
fixture = fixturedef.func
349+
def _wrap_async_fixture(fixturedef: FixtureDef) -> Callable:
350+
fixture_function = fixturedef.func
351351

352-
@functools.wraps(fixture)
352+
@functools.wraps(fixture_function)
353353
def _async_fixture_wrapper(request: FixtureRequest, **kwargs: Any):
354-
func = _perhaps_rebind_fixture_func(fixture, request.instance)
354+
func = _perhaps_rebind_fixture_func(fixture_function, request.instance)
355355
event_loop_fixture_id = _get_event_loop_fixture_id_for_async_fixture(
356356
request, func
357357
)
@@ -380,7 +380,7 @@ async def setup():
380380

381381
return result
382382

383-
fixturedef.func = _async_fixture_wrapper # type: ignore[misc]
383+
return _async_fixture_wrapper
384384

385385

386386
def _get_event_loop_fixture_id_for_async_fixture(

0 commit comments

Comments
 (0)