| 116 | |
| 117 | |
| 118 | def 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 | |
| 142 | def show_test_item(item: Item) -> None: |