51
51
)
52
52
53
53
if sys .version_info >= (3 , 10 ):
54
- from typing import Concatenate , ParamSpec
54
+ from typing import ParamSpec
55
55
else :
56
- from typing_extensions import Concatenate , ParamSpec
56
+ from typing_extensions import ParamSpec
57
57
58
58
if sys .version_info >= (3 , 11 ):
59
59
from asyncio import Runner
@@ -240,9 +240,9 @@ def _fixture_synchronizer(
240
240
"""Returns a synchronous function evaluating the specified fixture."""
241
241
fixture_function = resolve_fixture_function (fixturedef , request )
242
242
if inspect .isasyncgenfunction (fixturedef .func ):
243
- return _wrap_asyncgen_fixture (fixture_function , runner ) # type: ignore[arg-type]
243
+ return _wrap_asyncgen_fixture (fixture_function , runner , request ) # type: ignore[arg-type]
244
244
elif inspect .iscoroutinefunction (fixturedef .func ):
245
- return _wrap_async_fixture (fixture_function , runner ) # type: ignore[arg-type]
245
+ return _wrap_async_fixture (fixture_function , runner , request ) # type: ignore[arg-type]
246
246
else :
247
247
return fixturedef .func
248
248
@@ -268,18 +268,14 @@ def _wrap_asyncgen_fixture(
268
268
AsyncGenFixtureParams , AsyncGeneratorType [AsyncGenFixtureYieldType , Any ]
269
269
],
270
270
runner : Runner ,
271
- ) -> Callable [
272
- Concatenate [FixtureRequest , AsyncGenFixtureParams ], AsyncGenFixtureYieldType
273
- ]:
271
+ request : FixtureRequest ,
272
+ ) -> Callable [AsyncGenFixtureParams , AsyncGenFixtureYieldType ]:
274
273
@functools .wraps (fixture_function )
275
274
def _asyncgen_fixture_wrapper (
276
- request : FixtureRequest ,
277
275
* args : AsyncGenFixtureParams .args ,
278
276
** kwargs : AsyncGenFixtureParams .kwargs ,
279
277
):
280
- gen_obj = fixture_function (
281
- * args , ** _add_kwargs (fixture_function , kwargs , request )
282
- )
278
+ gen_obj = fixture_function (* args , ** kwargs )
283
279
284
280
async def setup ():
285
281
res = await gen_obj .__anext__ () # type: ignore[union-attr]
@@ -322,18 +318,16 @@ def _wrap_async_fixture(
322
318
AsyncFixtureParams , CoroutineType [Any , Any , AsyncFixtureReturnType ]
323
319
],
324
320
runner : Runner ,
325
- ) -> Callable [Concatenate [FixtureRequest , AsyncFixtureParams ], AsyncFixtureReturnType ]:
321
+ request : FixtureRequest ,
322
+ ) -> Callable [AsyncFixtureParams , AsyncFixtureReturnType ]:
326
323
327
324
@functools .wraps (fixture_function ) # type: ignore[arg-type]
328
325
def _async_fixture_wrapper (
329
- request : FixtureRequest ,
330
326
* args : AsyncFixtureParams .args ,
331
327
** kwargs : AsyncFixtureParams .kwargs ,
332
328
):
333
329
async def setup ():
334
- res = await fixture_function (
335
- * args , ** _add_kwargs (fixture_function , kwargs , request )
336
- )
330
+ res = await fixture_function (* args , ** kwargs )
337
331
return res
338
332
339
333
context = contextvars .copy_context ()
@@ -737,8 +731,6 @@ def pytest_fixture_setup(fixturedef: FixtureDef, request) -> object | None:
737
731
synchronizer = _fixture_synchronizer (fixturedef , runner , request )
738
732
_make_asyncio_fixture_function (synchronizer , loop_scope )
739
733
with MonkeyPatch .context () as c :
740
- if "request" not in fixturedef .argnames :
741
- c .setattr (fixturedef , "argnames" , (* fixturedef .argnames , "request" ))
742
734
c .setattr (fixturedef , "func" , synchronizer )
743
735
hook_result = yield
744
736
return hook_result
0 commit comments