-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
cacheprovider: pytest_collection_modifyitems: copy items #6411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -258,7 +258,7 @@ def pytest_collection_modifyitems(self, session, config, items): | |||
self._report_status = "no previously failed tests, " | |||
if self.config.getoption("last_failed_no_failures") == "none": | |||
self._report_status += "deselecting all items." | |||
config.hook.pytest_deselected(items=items) | |||
config.hook.pytest_deselected(items=items[:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
I wonder if it is a cache provider bug though... I mean, should every caller of pytest_deselected(items)
always send a copy over? 🤔
Sure, pytest_deselected
is kind of a weird hook, but I thought I would raise this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure myself, but here it is clear that the list is cleared just below at least.
FWIW, I've found an issue with auto-deselecting of tests when I was passing a set
there (and trying to items[:]
it).
As for the terminal plugin only the length is relevant anyway I think (#6409), but thought to keep stats
there like before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for sanity we should actually fail if session.items is passed by accident
this is a great and horrifying catch
the typical/presumed usage is collecting keep and drop in new lists, then passing drop after changing items, so the error is a honest misstake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for sanity we should actually fail if session.items is passed by accident
Makes sense, please consider creating a new issue for it.
the typical/presumed usage is collecting keep and drop in new lists, then passing drop after changing items, so the error is a honest misstake
I could not really parse this.
do not copy items (ref: pytest-dev#6411)
54b9938
to
2d2c67d
Compare
Noticed this with #6409, where
items
is stored/used as-is when there are no "deselected" stats yet.