-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Misleading error message when parameters are missing in the parametrize but presented in the test function #10113
Comments
This is the full output:
seems quite clear from that what the error is, no? |
Yes. But if we can improve the error message in the end, the DX would be even better. Plus sometimes there are a huge chunk of other logs in between, we have to scroll up to see the real cause of the failure. The reason why I put up the issue is that I was misled by the error message in the end. I spent some time to figure out why pytest didn’t get to pick up my test function. But in the end it’s the typo inside parametrize that caused the error. |
How about we report "couldn't collect" instead of "not found"? Almost as short, but accurate in a wider variety of cases. |
How much complexity will it bring to the codebase/logic if we want to explicitly display to user that If it is too complex, we can go for a simpler approach: use |
We already report that explicitly - see "errors" in the output example above - so I think it's just fixing the "short test summary info" to avoid claiming that any failure to collect was because the test was not found. |
currently we really cant know (as there wont be a collection node with the name after collection) since parameterization failed @The-Compiler i wonder if we could do a indirect parametrize with something that auto marks as "will fail" alternatively we could have exceptions in generate_tests yield some node that always fails/indicates collection errors |
I'd be okay with a simple change to the error message, but anything more complex really doesn't seem to be worth the trouble, IMHO. I really don't think the error message is confusing as-is, personally. |
I’ll let the core team make the decision then! Just trying to propose some rooms for improvement I found (might be very personally and subjectively). |
yeah, its a unfortunate edge case, the error itself causes the item not to be "find-able" what could help is taking a look at collection errors in requested paths and adding a note that a collection error was in the related files however thats also tricky, so I'd put it in at low prio |
I was able to duplicate the error. Working to fix the error message. |
As per #10145 (comment) I think a fix for this makes the message far more confusing for a way more common case. Thus, closing this. |
pip list
from the virtual environment you are usingI'm using pytest version 6.2.4.
Say we have the following function and a corresponding test function:
Running
pytest ./test_add.py::test_add
logs the following error message:But actually it fails because
arg2
is not presented in the parametrize decorator.Similar issue when the argument name is wrong.
The text was updated successfully, but these errors were encountered: