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

Function runtestprotocol

src/_pytest/runner.py:118–139  ·  view source on GitHub ↗
(
    item: Item, log: bool = True, nextitem: Optional[Item] = None
)

Source from the content-addressed store, hash-verified

116
117
118def runtestprotocol(
119 item: Item, log: bool = True, nextitem: Optional[Item] = None
120) -> List[TestReport]:
121 hasrequest = hasattr(item, "_request")
122 if hasrequest and not item._request: # type: ignore[attr-defined]
123 # This only happens if the item is re-run, as is done by
124 # pytest-rerunfailures.
125 item._initrequest() # type: ignore[attr-defined]
126 rep = call_and_report(item, "setup", log)
127 reports = [rep]
128 if rep.passed:
129 if item.config.getoption("setupshow", False):
130 show_test_item(item)
131 if not item.config.getoption("setuponly", False):
132 reports.append(call_and_report(item, "call", log))
133 reports.append(call_and_report(item, "teardown", log, nextitem=nextitem))
134 # After all teardown hooks have been called
135 # want funcargs and request info to go away.
136 if hasrequest:
137 item._request = False # type: ignore[attr-defined]
138 item.funcargs = None # type: ignore[attr-defined]
139 return reports
140
141
142def show_test_item(item: Item) -> None:

Callers 6

test_xfail_simpleMethod · 0.90
test_xfail_xpassedMethod · 0.90
pytest_runtest_protocolFunction · 0.85

Calls 5

call_and_reportFunction · 0.85
show_test_itemFunction · 0.85
_initrequestMethod · 0.80
appendMethod · 0.80
getoptionMethod · 0.45

Tested by 5

test_xfail_simpleMethod · 0.72
test_xfail_xpassedMethod · 0.72