(self, function: FixtureFunction)
| 1353 | check_ispytest(_ispytest) |
| 1354 | |
| 1355 | def __call__(self, function: FixtureFunction) -> FixtureFunctionDefinition: |
| 1356 | if inspect.isclass(function): |
| 1357 | raise ValueError("class fixtures not supported (maybe in the future)") |
| 1358 | |
| 1359 | if isinstance(function, FixtureFunctionDefinition): |
| 1360 | raise ValueError( |
| 1361 | f"@pytest.fixture is being applied more than once to the same function {function.__name__!r}" |
| 1362 | ) |
| 1363 | |
| 1364 | if hasattr(function, "pytestmark"): |
| 1365 | fail( |
| 1366 | "Marks cannot be applied to fixtures.\n" |
| 1367 | "See docs: https://docs.pytest.org/en/stable/deprecations.html#applying-a-mark-to-a-fixture-function" |
| 1368 | ) |
| 1369 | |
| 1370 | fixture_definition = FixtureFunctionDefinition( |
| 1371 | function=function, fixture_function_marker=self, _ispytest=True |
| 1372 | ) |
| 1373 | |
| 1374 | name = self.name or function.__name__ |
| 1375 | if name == "request": |
| 1376 | location = getlocation(function) |
| 1377 | fail( |
| 1378 | f"'request' is a reserved word for fixtures, use another name:\n {location}", |
| 1379 | pytrace=False, |
| 1380 | ) |
| 1381 | |
| 1382 | return fixture_definition |
| 1383 | |
| 1384 | |
| 1385 | # TODO: paramspec/return type annotation tracking and storing |
nothing calls this directly
no test coverage detected