Execution of fixture setup.
(
fixturedef: FixtureDef[FixtureValue], request: SubRequest
)
| 1303 | |
| 1304 | |
| 1305 | def pytest_fixture_setup( |
| 1306 | fixturedef: FixtureDef[FixtureValue], request: SubRequest |
| 1307 | ) -> FixtureValue: |
| 1308 | """Execution of fixture setup.""" |
| 1309 | kwargs = {} |
| 1310 | for argname in fixturedef.argnames: |
| 1311 | kwargs[argname] = request.getfixturevalue(argname) |
| 1312 | |
| 1313 | fixturefunc = resolve_fixture_function(fixturedef, request) |
| 1314 | my_cache_key = fixturedef.cache_key(request) |
| 1315 | |
| 1316 | if inspect.isasyncgenfunction(fixturefunc) or inspect.iscoroutinefunction( |
| 1317 | fixturefunc |
| 1318 | ): |
| 1319 | auto_str = " with autouse=True" if fixturedef._autouse else "" |
| 1320 | fail( |
| 1321 | f"{request.node.name!r} requested an async fixture {request.fixturename!r}{auto_str}, " |
| 1322 | "with no plugin or hook that handled it. This is an error, as pytest does not natively support it.\n" |
| 1323 | "See: https://docs.pytest.org/en/stable/deprecations.html#sync-test-depending-on-async-fixture", |
| 1324 | pytrace=False, |
| 1325 | ) |
| 1326 | |
| 1327 | try: |
| 1328 | result = call_fixture_func(fixturefunc, request, kwargs) |
| 1329 | except TEST_OUTCOME as e: |
| 1330 | if isinstance(e, skip.Exception): |
| 1331 | # The test requested a fixture which caused a skip. |
| 1332 | # Don't show the fixture as the skip location, as then the user |
| 1333 | # wouldn't know which test skipped. |
| 1334 | e._use_item_location = True |
| 1335 | fixturedef.cached_result = (None, my_cache_key, (e, e.__traceback__)) |
| 1336 | raise |
| 1337 | fixturedef.cached_result = (result, my_cache_key, None) |
| 1338 | return result |
| 1339 | |
| 1340 | |
| 1341 | @final |
nothing calls this directly
no test coverage detected