Skip to content

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

Merged
merged 3 commits into from
Sep 9, 2019
Merged

bpo-34596: Fallback to a default reason when @unittest.skip is uncalled #9082

merged 3 commits into from
Sep 9, 2019

Conversation

Naitreey
Copy link
Contributor

@Naitreey Naitreey commented Sep 6, 2018

  • Provide a default reason string when @unittest.skip decorator is used in uncalled form.
  • Add a test case for this change.

https://bugs.python.org/issue34596

@the-knights-who-say-ni
Copy link

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!

Copy link
Member

@zware zware left a 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.

Copy link
Member

@berkerpeksag berkerpeksag left a 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.

@@ -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'
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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`

@@ -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'
Copy link
Member

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.

@bedevere-bot
Copy link

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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@Naitreey
Copy link
Contributor Author

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.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@zware, @kushaldas: please review the changes made to this pull request.

@serhiy-storchaka
Copy link
Member

Even if this proposition be accepted, it is a new feature and should not be backported.

@serhiy-storchaka serhiy-storchaka added type-feature A feature request or enhancement and removed needs backport to 2.7 labels Dec 8, 2018
@csabella csabella requested review from kushaldas and zware May 31, 2019 11:10
@csabella csabella requested review from berkerpeksag and removed request for zware May 31, 2019 11:10
Copy link
Member

@berkerpeksag berkerpeksag left a 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.

@bedevere-bot
Copy link

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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@voidspace
Copy link
Contributor

I'm going to land this PR as is on 3.8 and master.

@voidspace voidspace self-assigned this Sep 9, 2019
@voidspace voidspace merged commit d5fd75c into python:master Sep 9, 2019
@miss-islington
Copy link
Contributor

Thanks @Naitreey for the PR, and @voidspace for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@bedevere-bot
Copy link

@voidspace: Please replace # with GH- in the commit message next time. Thanks!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2019
…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]>
@bedevere-bot
Copy link

GH-15781 is a backport of this pull request to the 3.8 branch.

voidspace pushed a commit that referenced this pull request Sep 9, 2019
…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]>
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants