| 198 | @final |
| 199 | @attr.s(frozen=True, init=False, auto_attribs=True) |
| 200 | class Mark: |
| 201 | #: Name of the mark. |
| 202 | name: str |
| 203 | #: Positional arguments of the mark decorator. |
| 204 | args: Tuple[Any, ...] |
| 205 | #: Keyword arguments of the mark decorator. |
| 206 | kwargs: Mapping[str, Any] |
| 207 | |
| 208 | #: Source Mark for ids with parametrize Marks. |
| 209 | _param_ids_from: Optional["Mark"] = attr.ib(default=None, repr=False) |
| 210 | #: Resolved/generated ids with parametrize Marks. |
| 211 | _param_ids_generated: Optional[Sequence[str]] = attr.ib(default=None, repr=False) |
| 212 | |
| 213 | def __init__( |
| 214 | self, |
| 215 | name: str, |
| 216 | args: Tuple[Any, ...], |
| 217 | kwargs: Mapping[str, Any], |
| 218 | param_ids_from: Optional["Mark"] = None, |
| 219 | param_ids_generated: Optional[Sequence[str]] = None, |
| 220 | *, |
| 221 | _ispytest: bool = False, |
| 222 | ) -> None: |
| 223 | """:meta private:""" |
| 224 | check_ispytest(_ispytest) |
| 225 | # Weirdness to bypass frozen=True. |
| 226 | object.__setattr__(self, "name", name) |
| 227 | object.__setattr__(self, "args", args) |
| 228 | object.__setattr__(self, "kwargs", kwargs) |
| 229 | object.__setattr__(self, "_param_ids_from", param_ids_from) |
| 230 | object.__setattr__(self, "_param_ids_generated", param_ids_generated) |
| 231 | |
| 232 | def _has_param_ids(self) -> bool: |
| 233 | return "ids" in self.kwargs or len(self.args) >= 4 |
| 234 | |
| 235 | def combined_with(self, other: "Mark") -> "Mark": |
| 236 | """Return a new Mark which is a combination of this |
| 237 | Mark and another Mark. |
| 238 | |
| 239 | Combines by appending args and merging kwargs. |
| 240 | |
| 241 | :param Mark other: The mark to combine with. |
| 242 | :rtype: Mark |
| 243 | """ |
| 244 | assert self.name == other.name |
| 245 | |
| 246 | # Remember source of ids with parametrize Marks. |
| 247 | param_ids_from: Optional[Mark] = None |
| 248 | if self.name == "parametrize": |
| 249 | if other._has_param_ids(): |
| 250 | param_ids_from = other |
| 251 | elif self._has_param_ids(): |
| 252 | param_ids_from = self |
| 253 | |
| 254 | return Mark( |
| 255 | self.name, |
| 256 | self.args + other.args, |
| 257 | dict(self.kwargs, **other.kwargs), |
no outgoing calls
no test coverage detected