MCPcopy Create free account
hub / github.com/pytest-dev/pytest / __call__

Method __call__

src/_pytest/fixtures.py:1197–1220  ·  view source on GitHub ↗
(self, function: FixtureFunction)

Source from the content-addressed store, hash-verified

1195 name: Optional[str] = None
1196
1197 def __call__(self, function: FixtureFunction) -> FixtureFunction:
1198 if inspect.isclass(function):
1199 raise ValueError("class fixtures not supported (maybe in the future)")
1200
1201 if getattr(function, "_pytestfixturefunction", False):
1202 raise ValueError(
1203 "fixture is being applied more than once to the same function"
1204 )
1205
1206 function = wrap_function_to_error_out_if_called_directly(function, self)
1207
1208 name = self.name or function.__name__
1209 if name == "request":
1210 location = getlocation(function)
1211 fail(
1212 "'request' is a reserved word for fixtures, use another name:\n {}".format(
1213 location
1214 ),
1215 pytrace=False,
1216 )
1217
1218 # Type ignored because https://github.com/python/mypy/issues/2087.
1219 function._pytestfixturefunction = self # type: ignore[attr-defined]
1220 return function
1221
1222
1223@overload

Callers

nothing calls this directly

Calls 4

getlocationFunction · 0.90
failFunction · 0.90
formatMethod · 0.45

Tested by

no test coverage detected