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

Method test_mark_closest

testing/test_mark.py:633–657  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

631 self.assert_markers(items, test_foo=("a", "b", "c"), test_bar=("a", "b", "d"))
632
633 def test_mark_closest(self, pytester: Pytester) -> None:
634 p = pytester.makepyfile(
635 """
636 import pytest
637
638 @pytest.mark.c(location="class")
639 class Test:
640 @pytest.mark.c(location="function")
641 def test_has_own(self):
642 pass
643
644 def test_has_inherited(self):
645 pass
646
647 """
648 )
649 items, _rec = pytester.inline_genitems(p)
650 has_own, has_inherited = items
651 has_own_marker = has_own.get_closest_marker("c")
652 has_inherited_marker = has_inherited.get_closest_marker("c")
653 assert has_own_marker is not None
654 assert has_inherited_marker is not None
655 assert has_own_marker.kwargs == {"location": "function"}
656 assert has_inherited_marker.kwargs == {"location": "class"}
657 assert has_own.get_closest_marker("missing") is None
658
659 def test_mark_with_wrong_marker(self, pytester: Pytester) -> None:
660 reprec = pytester.inline_runsource(

Callers

nothing calls this directly

Calls 3

get_closest_markerMethod · 0.80
makepyfileMethod · 0.45
inline_genitemsMethod · 0.45

Tested by

no test coverage detected