Store a Mark on an object. This is used to implement the Mark declarations/decorators correctly.
(obj, mark: Mark)
| 479 | |
| 480 | |
| 481 | def 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 |
no test coverage detected