Objects passed to the :hook:`pytest_generate_tests` hook. They help to inspect a test function and to generate tests according to test configuration or values specified in the class or module where a test function is defined.
| 996 | |
| 997 | @final |
| 998 | class Metafunc: |
| 999 | """Objects passed to the :hook:`pytest_generate_tests` hook. |
| 1000 | |
| 1001 | They help to inspect a test function and to generate tests according to |
| 1002 | test configuration or values specified in the class or module where a |
| 1003 | test function is defined. |
| 1004 | """ |
| 1005 | |
| 1006 | def __init__( |
| 1007 | self, |
| 1008 | definition: "FunctionDefinition", |
| 1009 | fixtureinfo: fixtures.FuncFixtureInfo, |
| 1010 | config: Config, |
| 1011 | cls=None, |
| 1012 | module=None, |
| 1013 | *, |
| 1014 | _ispytest: bool = False, |
| 1015 | ) -> None: |
| 1016 | check_ispytest(_ispytest) |
| 1017 | |
| 1018 | #: Access to the underlying :class:`_pytest.python.FunctionDefinition`. |
| 1019 | self.definition = definition |
| 1020 | |
| 1021 | #: Access to the :class:`pytest.Config` object for the test session. |
| 1022 | self.config = config |
| 1023 | |
| 1024 | #: The module object where the test function is defined in. |
| 1025 | self.module = module |
| 1026 | |
| 1027 | #: Underlying Python test function. |
| 1028 | self.function = definition.obj |
| 1029 | |
| 1030 | #: Set of fixture names required by the test function. |
| 1031 | self.fixturenames = fixtureinfo.names_closure |
| 1032 | |
| 1033 | #: Class object where the test function is defined in or ``None``. |
| 1034 | self.cls = cls |
| 1035 | |
| 1036 | self._arg2fixturedefs = fixtureinfo.name2fixturedefs |
| 1037 | |
| 1038 | # Result of parametrize(). |
| 1039 | self._calls: List[CallSpec2] = [] |
| 1040 | |
| 1041 | def parametrize( |
| 1042 | self, |
| 1043 | argnames: Union[str, List[str], Tuple[str, ...]], |
| 1044 | argvalues: Iterable[Union[ParameterSet, Sequence[object], object]], |
| 1045 | indirect: Union[bool, Sequence[str]] = False, |
| 1046 | ids: Optional[ |
| 1047 | Union[ |
| 1048 | Iterable[Union[None, str, float, int, bool]], |
| 1049 | Callable[[Any], Optional[object]], |
| 1050 | ] |
| 1051 | ] = None, |
| 1052 | scope: "Optional[_ScopeName]" = None, |
| 1053 | *, |
| 1054 | _param_mark: Optional[Mark] = None, |
| 1055 | ) -> None: |