-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
MAINT Shorten parametrized test names with long error messages #21364
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
Here is the output of pytest for the following command:
|
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.
LGTM
@@ -1654,6 +1654,9 @@ def test_forest_degenerate_feature_importances(): | |||
r"'\<class 'numpy.ndarray'\>'", | |||
), | |||
], | |||
# Avoid long error messages in test names: | |||
# https://github.com/scikit-learn/scikit-learn/issues/21362 | |||
ids=lambda x: "error" if isinstance(x, str) and len(x) > 10 else x, |
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.
After some testing, I think it's the inclusion of ]
that is causing that error.
If an exc_msg
were to have len(x) <=10 and include a ]
, vscode would still fail to parse the collected test. If we want to have shorter test names and avoid the error:
ids=lambda x: "error" if isinstance(x, str) and len(x) > 10 else x, | |
ids=lambda x: x[:10].replace("]", "") if isinstance(x, str) else x, |
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.
Yes I agree about ]
but I also think they will fix the problem upstream in VS Code (because it used to work, it's a recent regression).
So my idea was to make a fix to temporarily hide the VS Code bug and at the same time shorten those test names that are too verbose.
But ok with your suggestion. I think we can drop the .replace("]", "")
once the bug is fixed in VS Code.
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
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.
I am okay with this temporary fix and revert when microsoft/vscode-python#17676 is fixed.
Still LGTM to me. I'm ok to revert the "replace" stuff when vscode is fixed but I'd like to keep the short id because it makes the pytest rendering more readable |
…t-learn#21364) * Apply suggestions from code review Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
* Apply suggestions from code review Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
…t-learn#21364) * Apply suggestions from code review Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Fixes #21362.
I think those long error messages are too long anyways.