(
cls,
argnames: str | Sequence[str],
argvalues: Iterable[ParameterSet | Sequence[object] | object],
func,
config: Config,
nodeid: str,
)
| 191 | |
| 192 | @classmethod |
| 193 | def _for_parametrize( |
| 194 | cls, |
| 195 | argnames: str | Sequence[str], |
| 196 | argvalues: Iterable[ParameterSet | Sequence[object] | object], |
| 197 | func, |
| 198 | config: Config, |
| 199 | nodeid: str, |
| 200 | ) -> tuple[Sequence[str], list[ParameterSet]]: |
| 201 | if not isinstance(argvalues, Collection): |
| 202 | warnings.warn( |
| 203 | PARAMETRIZE_NON_COLLECTION_ITERABLE.format( |
| 204 | nodeid=nodeid, |
| 205 | type_name=type(argvalues).__name__, |
| 206 | ), |
| 207 | stacklevel=3, |
| 208 | ) |
| 209 | |
| 210 | argnames, force_tuple = cls._parse_parametrize_args(argnames, argvalues) |
| 211 | parameters = cls._parse_parametrize_parameters(argvalues, force_tuple) |
| 212 | del argvalues |
| 213 | |
| 214 | if parameters: |
| 215 | # Check all parameter sets have the correct number of values. |
| 216 | for param in parameters: |
| 217 | if len(param.values) != len(argnames): |
| 218 | msg = ( |
| 219 | '{nodeid}: in "parametrize" the number of names ({names_len}):\n' |
| 220 | " {names}\n" |
| 221 | "must be equal to the number of values ({values_len}):\n" |
| 222 | " {values}" |
| 223 | ) |
| 224 | fail( |
| 225 | msg.format( |
| 226 | nodeid=nodeid, |
| 227 | values=param.values, |
| 228 | names=argnames, |
| 229 | names_len=len(argnames), |
| 230 | values_len=len(param.values), |
| 231 | ), |
| 232 | pytrace=False, |
| 233 | ) |
| 234 | else: |
| 235 | # Empty parameter set (likely computed at runtime): create a single |
| 236 | # parameter set with NOTSET values, with the "empty parameter set" mark applied to it. |
| 237 | mark = get_empty_parameterset_mark(config, argnames, func) |
| 238 | parameters.append( |
| 239 | ParameterSet( |
| 240 | values=(NOTSET,) * len(argnames), marks=[mark], id="NOTSET" |
| 241 | ) |
| 242 | ) |
| 243 | return argnames, parameters |
| 244 | |
| 245 | |
| 246 | @final |
no test coverage detected