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

Function store_mark

src/_pytest/mark/structures.py:481–498  ·  view source on GitHub ↗

Store a Mark on an object. This is used to implement the Mark declarations/decorators correctly.

(obj, mark: Mark)

Source from the content-addressed store, hash-verified

479
480
481def store_mark(obj, mark: Mark) -> None:
482 """Store a Mark on an object.
483
484 This is used to implement the Mark declarations/decorators correctly.
485 """
486 assert isinstance(mark, Mark), mark
487
488 from ..fixtures import getfixturemarker
489
490 if getfixturemarker(obj) is not None:
491 fail(
492 "Marks cannot be applied to fixtures.\n"
493 "See docs: https://docs.pytest.org/en/stable/deprecations.html#applying-a-mark-to-a-fixture-function"
494 )
495
496 # Always reassign name to avoid updating pytestmark in a reference that
497 # was only borrowed.
498 obj.pytestmark = [*get_unpacked_marks(obj, consider_mro=False), mark]
499
500
501# Typing for builtin pytest marks. This is cheating; it gives builtin marks

Callers 1

__call__Method · 0.85

Calls 2

getfixturemarkerFunction · 0.85
get_unpacked_marksFunction · 0.85

Tested by

no test coverage detected