-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-34596: Fallback to a default reason when @unittest.skip is uncalled #9082
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
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
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. I would like to hear from the maintainers of unittest before merging, though.
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.
https://docs.python.org/3/library/unittest.html#unittest.skip documentations needs to be updated as well.
Lib/unittest/case.py
Outdated
@@ -98,6 +99,10 @@ def skip_wrapper(*args, **kwargs): | |||
test_item.__unittest_skip__ = True | |||
test_item.__unittest_skip_why__ = reason | |||
return test_item | |||
if isinstance(reason, types.FunctionType): | |||
test_item = reason | |||
reason = 'unconditionally' |
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 think it would be better if set reason
to None
.
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 would prefer to have the reason to ""
, this will be also similar to the Java world.
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'm fine with that. I suggested "unconditionally" mostly just because I had no better suggestion; the empty string probably should have been what I suggested in the first place :)
@@ -0,0 +1,2 @@ | |||
Fallback to a default reason when @unittest.skip is uncalled. Patch by |
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.
@unittest.skip -> :func:`unittest.skip`
Lib/unittest/case.py
Outdated
@@ -98,6 +99,10 @@ def skip_wrapper(*args, **kwargs): | |||
test_item.__unittest_skip__ = True | |||
test_item.__unittest_skip_why__ = reason | |||
return test_item | |||
if isinstance(reason, types.FunctionType): | |||
test_item = reason | |||
reason = 'unconditionally' |
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 would prefer to have the reason to ""
, this will be also similar to the Java world.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again. Except for the documentation part. From the ongoing discussion on bug tracker, I'm not sure this change is strictly for not breaking existing user code, or intended as a new feature. |
Thanks for making the requested changes! @zware, @kushaldas: please review the changes made to this pull request. |
Even if this proposition be accepted, it is a new feature and should not be backported. |
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.
Looking at this again, now I agree with Serhiy's suggestion at https://bugs.python.org/issue34596#msg324836
All skip*() APIs require 'reason' and if we'd accept this PR as-is, I'm sure we are going to get "why don't you make reason optional in skipIf() as well?" reports. I prefer to keep these APIs simpler.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I'm going to land this PR as is on 3.8 and master. |
Thanks @Naitreey for the PR, and @voidspace for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
@voidspace: Please replace |
…ed (pythonGH-9082) * bpo-34596: Fallback to a default reason when @unittest.skip is uncalled * Change default reason to empty string * Fix rst formatting of NEWS entry (cherry picked from commit d5fd75c) Co-authored-by: Naitree Zhu <[email protected]>
GH-15781 is a backport of this pull request to the 3.8 branch. |
…ed (GH-9082) (#15781) * bpo-34596: Fallback to a default reason when @unittest.skip is uncalled * Change default reason to empty string * Fix rst formatting of NEWS entry (cherry picked from commit d5fd75c) Co-authored-by: Naitree Zhu <[email protected]>
…ed (python#9082) * bpo-34596: Fallback to a default reason when @unittest.skip is uncalled * Change default reason to empty string * Fix rst formatting of NEWS entry
@unittest.skip
decorator is used in uncalled form.https://bugs.python.org/issue34596