-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
inconsistent behavior report vs collect in Pytest 7 (corner case) #9724
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
Hi @stanislavlevin, Seems related to #9144, and is considered a feature. Note that of course pytest only "sees" the second Closing this then. 👍 |
Hi, @nicoddemus, thank you for reply. I expected that the order of report == the order of collect. Was I wrong? |
in pytest 6 there was an error prone attempt to find the location of the test by loading the tests' source and traversing through the ast and source in pytest 7 the ordering is what cpython tells us it is (due to dictionaries maintaining insertion order and the module ~essentially being an object with the change in behaviour "makes sense" here -- but the code seems wrong (duplicate definitions are going to clobber themselves) -- so to me this seems "garbage in garbage out" |
@asottile i believe the confusion comes from the fact that a later defined "replacement" will retain the order spot from the earlier insert im a bit on the edge about deciding whether its a regression, as it practically only hits when that particular type of user error happens a warning about that case may help people but ultimately its a thing a linter helps with |
Agreed, linters probably already help with that. |
flake8 (via pyflakes) catches this for instance |
test example should include two test functions having the same name (this is just an example):
Pytest 7:
Pytest 6:
With Pytest 7 tests are ordered by definition ignoring possible re-definition.
I can't find documented behavior for duplicated test functions, so feel free to close this ticket if this is something not supported.
The text was updated successfully, but these errors were encountered: