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

Method test_select_extra_keywords

testing/test_mark.py:796–824  ·  view source on GitHub ↗
(self, pytester: Pytester, keyword)

Source from the content-addressed store, hash-verified

794 ],
795 )
796 def test_select_extra_keywords(self, pytester: Pytester, keyword) -> None:
797 p = pytester.makepyfile(
798 test_select="""
799 def test_1():
800 pass
801 class TestClass(object):
802 def test_2(self):
803 pass
804 """
805 )
806 pytester.makepyfile(
807 conftest="""
808 import pytest
809 @pytest.hookimpl(hookwrapper=True)
810 def pytest_pycollect_makeitem(name):
811 outcome = yield
812 if name == "TestClass":
813 item = outcome.get_result()
814 item.extra_keyword_matches.add("xxx")
815 """
816 )
817 reprec = pytester.inline_run(p.parent, "-s", "-k", keyword)
818 print("keyword", repr(keyword))
819 passed, skipped, failed = reprec.listoutcomes()
820 assert len(passed) == 1
821 assert passed[0].nodeid.endswith("test_2")
822 dlist = reprec.getcalls("pytest_deselected")
823 assert len(dlist) == 1
824 assert dlist[0].items[0].name == "test_1"
825
826 def test_select_starton(self, pytester: Pytester) -> None:
827 threepass = pytester.makepyfile(

Callers

nothing calls this directly

Calls 4

listoutcomesMethod · 0.80
getcallsMethod · 0.80
makepyfileMethod · 0.45
inline_runMethod · 0.45

Tested by

no test coverage detected