Dynamically add a marker object to the node. :param append: Whether to append the marker, or prepend it.
(
self, marker: Union[str, MarkDecorator], append: bool = True
)
| 336 | return chain |
| 337 | |
| 338 | def add_marker( |
| 339 | self, marker: Union[str, MarkDecorator], append: bool = True |
| 340 | ) -> None: |
| 341 | """Dynamically add a marker object to the node. |
| 342 | |
| 343 | :param append: |
| 344 | Whether to append the marker, or prepend it. |
| 345 | """ |
| 346 | from _pytest.mark import MARK_GEN |
| 347 | |
| 348 | if isinstance(marker, MarkDecorator): |
| 349 | marker_ = marker |
| 350 | elif isinstance(marker, str): |
| 351 | marker_ = getattr(MARK_GEN, marker) |
| 352 | else: |
| 353 | raise ValueError("is not a string or pytest.mark.* Marker") |
| 354 | self.keywords[marker_.name] = marker_ |
| 355 | if append: |
| 356 | self.own_markers.append(marker_.mark) |
| 357 | else: |
| 358 | self.own_markers.insert(0, marker_.mark) |
| 359 | |
| 360 | def iter_markers(self, name: Optional[str] = None) -> Iterator[Mark]: |
| 361 | """Iterate over all markers of the node. |