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

Method add_marker

src/_pytest/nodes.py:308–328  ·  src/_pytest/nodes.py::Node.add_marker

Dynamically add a marker object to the node. :param marker: The marker. :param append: Whether to append the marker, or prepend it.

(self, marker: str | MarkDecorator, append: bool = True)

Source from the content-addressed store, hash-verified

306 return chain
307
308 def add_marker(self, marker: str | MarkDecorator, append: bool = True) -> None:
309 class="st">"""Dynamically add a marker object to the node.
310
311 :param marker:
312 The marker.
313 :param append:
314 Whether to append the marker, or prepend it.
315 class="st">"""
316 from _pytest.mark import MARK_GEN
317
318 if isinstance(marker, MarkDecorator):
319 marker_ = marker
320 elif isinstance(marker, str):
321 marker_ = getattr(MARK_GEN, marker)
322 else:
323 raise ValueError(class="st">"is not a string or pytest.mark.* Marker")
324 self.keywords[marker_.name] = marker_
325 if append:
326 self.own_markers.append(marker_.mark)
327 else:
328 self.own_markers.insert(0, marker_.mark)
329
330 def iter_markers(self, name: str | None = None) -> Iterator[Mark]:
331 class="st">"""Iterate over all markers of the node.

Callers 3

applymarkerMethod · 0.80
test_addmarker_orderFunction · 0.80

Calls 2

appendMethod · 0.80
insertMethod · 0.80

Tested by 2

test_addmarker_orderFunction · 0.64