(
self, config: Config, items: List[nodes.Item]
)
| 66 | self.session = session |
| 67 | |
| 68 | def pytest_collection_modifyitems( |
| 69 | self, config: Config, items: List[nodes.Item] |
| 70 | ) -> None: |
| 71 | if not self.lastfailed: |
| 72 | self.report_status = "no previously failed tests, not skipping." |
| 73 | return |
| 74 | |
| 75 | # check all item nodes until we find a match on last failed |
| 76 | failed_index = None |
| 77 | for index, item in enumerate(items): |
| 78 | if item.nodeid == self.lastfailed: |
| 79 | failed_index = index |
| 80 | break |
| 81 | |
| 82 | # If the previously failed test was not found among the test items, |
| 83 | # do not skip any tests. |
| 84 | if failed_index is None: |
| 85 | self.report_status = "previously failed test not found, not skipping." |
| 86 | else: |
| 87 | self.report_status = f"skipping {failed_index} already passed items." |
| 88 | deselected = items[:failed_index] |
| 89 | del items[:failed_index] |
| 90 | config.hook.pytest_deselected(items=deselected) |
| 91 | |
| 92 | def pytest_runtest_logreport(self, report: TestReport) -> None: |
| 93 | if report.failed: |
nothing calls this directly
no test coverage detected