Skip to content

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

Merged
voidspace merged 3 commits into
python:masterfrom
Naitreey:bpo-34596
Sep 9, 2019
Merged

bpo-34596: Fallback to a default reason when @unittest.skip is uncalled#9082
voidspace merged 3 commits into
python:masterfrom
Naitreey:bpo-34596

Conversation

@Naitreey

@Naitreey Naitreey commented Sep 6, 2018

Copy link
Copy Markdown
Contributor
  • 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
Copy Markdown

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!

@zware zware left a comment

Copy link
Copy Markdown
Member

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.

@berkerpeksag berkerpeksag left a comment

Copy link
Copy Markdown
Member

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.

Comment thread Lib/unittest/case.py Outdated
return test_item
if isinstance(reason, types.FunctionType):
test_item = reason
reason = 'unconditionally'

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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`

Comment thread Lib/unittest/case.py Outdated
return test_item
if isinstance(reason, types.FunctionType):
test_item = reason
reason = 'unconditionally'

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

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
Copy Markdown
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
Copy Markdown

Thanks for making the requested changes!

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

@serhiy-storchaka

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

@berkerpeksag berkerpeksag left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

@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 <Naitreey@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

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 <Naitreey@gmail.com>
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