-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Issue with duplicates handling in Pytest 8 #12083
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
Comments
Thanks for the bug report @nonatomiclabs, I agree the new behavior is buggy. I will take a look. The duplicate handling is a bit of a headache and as you said it was quite broken also before #11646. |
I started looking at this, but it's surprisingly tricky to come up with a self-consistent, intuitive and reasonably backward-compatible logic for the duplicate handling, if you think about it. Though I'll keep trying :) |
First, some explanations of the details that are relevant to duplicate handling, then some thoughts on how it should work. Collection argumentsThe collection arguments are the inputs that pytest starts collecting from. These are usually the positional command line arguments but can also be A collection arg has two parts - the path and (optionally) and parts within the file. All of the collection args are given to
|
Hi, any plan to work on this, someone? |
Following an upgrade to Pytest 8, we are seeing a change in the way duplicate items are handled, which does not seem logical/expected to me.
Current behavior
Let's assume we have the following directory structure:
With Pytest 7, if we call
pytest test_one.py tests --collect-only
, it returns 3tests:
With Pytest 8, we get only one:
After looking a bit at Pytest's internals, the change looks related to the refactoring done in #11646, where the duplicates handling logic was moved away from the former
_collectfile
method (which, I guess, operate on a file-per-file basis), to be consolidated ingenitems()
(in which a single duplicate in a node will result in the complete node being ignored).Expected behavior
I would expect
test_one.py
not to prevent the further collection of tests insubdirectory
, even though it's a duplicate.To be honest, I'm also a bit puzzled by the previous behavior in Pytest 7, as I wouldn't have expected to see
tests/test_one.py
twice (as I didn't pass the--keep-duplicates
option).Are my expectations correct in the first place, or did I misunderstand the changes to the test collection and the behavior is expected?
Additional information
The text was updated successfully, but these errors were encountered: