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

Method pytest_collection_modifyitems

src/_pytest/stepwise.py:68–90  ·  view source on GitHub ↗
(
        self, config: Config, items: List[nodes.Item]
    )

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 1

pytest_deselectedMethod · 0.80

Tested by

no test coverage detected