| 1182 | @final |
| 1183 | @attr.s(frozen=True, auto_attribs=True) |
| 1184 | class FixtureFunctionMarker: |
| 1185 | scope: "Union[_ScopeName, Callable[[str, Config], _ScopeName]]" |
| 1186 | params: Optional[Tuple[object, ...]] = attr.ib(converter=_params_converter) |
| 1187 | autouse: bool = False |
| 1188 | ids: Union[ |
| 1189 | Tuple[Union[None, str, float, int, bool], ...], |
| 1190 | Callable[[Any], Optional[object]], |
| 1191 | ] = attr.ib( |
| 1192 | default=None, |
| 1193 | converter=_ensure_immutable_ids, |
| 1194 | ) |
| 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 |