MCPcopy
hub / github.com/pytest-dev/pytest / _idval_from_function

Method _idval_from_function

src/_pytest/python.py:1011–1025  ·  view source on GitHub ↗

Try to make an ID for a parameter in a ParameterSet using the user-provided id callable, if given.

(self, val: object, argname: str, idx: int)

Source from the content-addressed store, hash-verified

1009 return self._idval_from_argname(argname, idx)
1010
1011 def _idval_from_function(self, val: object, argname: str, idx: int) -> str | None:
1012 """Try to make an ID for a parameter in a ParameterSet using the
1013 user-provided id callable, if given."""
1014 if self.idfn is None:
1015 return None
1016 try:
1017 id = self.idfn(val)
1018 except Exception as e:
1019 prefix = f"{self.nodeid}: " if self.nodeid is not None else ""
1020 msg = "error raised while trying to determine id of parameter '{}' at position {}"
1021 msg = prefix + msg.format(argname, idx)
1022 raise ValueError(msg) from e
1023 if id is None:
1024 return None
1025 return self._idval_from_value(id)
1026
1027 def _idval_from_hook(self, val: object, argname: str) -> str | None:
1028 """Try to make an ID for a parameter in a ParameterSet by calling the

Callers 1

_idvalMethod · 0.95

Calls 2

_idval_from_valueMethod · 0.95
formatMethod · 0.45

Tested by

no test coverage detected