MCPcopy Create free account
hub / github.com/pytest-dev/pytest / add_marker

Method add_marker

src/_pytest/nodes.py:338–358  ·  view source on GitHub ↗

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
    )

Source from the content-addressed store, hash-verified

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.

Callers 4

applymarkerMethod · 0.80
test_addmarker_orderFunction · 0.80

Calls 2

appendMethod · 0.80
insertMethod · 0.80

Tested by 2

test_addmarker_orderFunction · 0.64