Skip to content

Commit ac20c93

Browse files
committed
cacheprovider: pytest_collection_modifyitems: copy items
1 parent 0fa3596 commit ac20c93

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/_pytest/cacheprovider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def pytest_collection_modifyitems(self, session, config, items):
258258
self._report_status = "no previously failed tests, "
259259
if self.config.getoption("last_failed_no_failures") == "none":
260260
self._report_status += "deselecting all items."
261-
config.hook.pytest_deselected(items=items)
261+
config.hook.pytest_deselected(items=items[:])
262262
items[:] = []
263263
else:
264264
self._report_status += "not deselecting items."

testing/test_cacheprovider.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,26 @@ def test_2(): pass
681681
result.stdout.fnmatch_lines(["*2 passed*"])
682682
result = testdir.runpytest("--lf", "--lfnf", "all")
683683
result.stdout.fnmatch_lines(["*2 passed*"])
684+
685+
testdir.makeconftest(
686+
"""
687+
deselected = []
688+
689+
def pytest_deselected(items):
690+
global deselected
691+
deselected = items
692+
693+
def pytest_sessionfinish():
694+
print("\\ndeselected={}".format(len(deselected)))
695+
"""
696+
)
697+
684698
result = testdir.runpytest("--lf", "--lfnf", "none")
685699
result.stdout.fnmatch_lines(
686700
[
687701
"collected 2 items / 2 deselected",
688702
"run-last-failure: no previously failed tests, deselecting all items.",
703+
"deselected=2",
689704
"* 2 deselected in *",
690705
]
691706
)

0 commit comments

Comments
 (0)