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

Method test_mark_closest

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

Source from the content-addressed store, hash-verified

562 self.assert_markers(items, test_foo=("a", "b", "c"), test_bar=("a", "b", "d"))
563
564 def test_mark_closest(self, pytester: Pytester) -> None:
565 p = pytester.makepyfile(
566 """
567 import pytest
568
569 @pytest.mark.c(location="class")
570 class Test:
571 @pytest.mark.c(location="function")
572 def test_has_own(self):
573 pass
574
575 def test_has_inherited(self):
576 pass
577
578 """
579 )
580 items, rec = pytester.inline_genitems(p)
581 has_own, has_inherited = items
582 has_own_marker = has_own.get_closest_marker("c")
583 has_inherited_marker = has_inherited.get_closest_marker("c")
584 assert has_own_marker is not None
585 assert has_inherited_marker is not None
586 assert has_own_marker.kwargs == {"location": "function"}
587 assert has_inherited_marker.kwargs == {"location": "class"}
588 assert has_own.get_closest_marker("missing") is None
589
590 def test_mark_with_wrong_marker(self, pytester: Pytester) -> None:
591 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