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
bpo-25750: add testcase on bad descriptor __get__() #9084
Conversation
Hi @serhiy-storchaka, in PR #6118 I wrote that I wasn't really happy about adding an unit test on such really tiny corner case. What do you think? Is it ok to add such test? The unit test is indirectly restricted to CPython since it requires _testcapi. |
If that's a problem, I could do
|
NEWS entry is already there (from #6118). Even if it's an edge case, I think the regression test should be merged. |
@encukou: Would you just mind to approve the change in that case? @serhiy-storchaka: What do you think? I don't have an opinion strong enough against this change to block it. @encukou: if you want to, please go ahead :-) |
@@ -4757,6 +4762,22 @@ def __call__(self, arg): | |||
self.assertRegex(repr(method), | |||
r"<bound method qualname of <object object at .*>>") | |||
|
|||
@unittest.skipIf(_testcapi is None, 'need the _testcapi module') |
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.
We can wrap the test with @cpython_only
.
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 wanted to propose the same change, but IMHO @unittest.skipIf(_testcapi is None, ...) is fine since _testcapi is specific to CPython and it's a common pattern.
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.
cpython_only
serves also documenting purpose. It is common to decorate all tests that use _testcapi
with cpython_only
.
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.
@jdemeyer: Would you mind to add @cpython_only? IMHO it's better to add it first, before "_testcapi is 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.
Would you mind to add @cpython_only? IMHO it's better to add it first, before "_testcapi is None".
Do we really need both? Doesn't @cpython_only
imply that _testcapi
is available?
@@ -4757,6 +4762,22 @@ def __call__(self, arg): | |||
self.assertRegex(repr(method), | |||
r"<bound method qualname of <object object at .*>>") | |||
|
|||
@unittest.skipIf(_testcapi is None, 'need the _testcapi module') |
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.
cpython_only
serves also documenting purpose. It is common to decorate all tests that use _testcapi
with cpython_only
.
I was the one who blocked the addition of the test. It seems like everybody likes the test, there was just a minor discussion on the @cpython_only decorator. I dislike seeing this PR stuck for such non-blocker issue, so I decided to merge it. Thanks @jdemeyer for this test. Sorry for being so pendantic :-) |
I propose to not backport this new test to stable Python version. IMHO this test is borderline, I prefer to see how it goes in Python 3.8 first. |
This adds a testcase for bpo-25750 (#6118). This is a separate pull request since the testcase is possibly controversial.
https://bugs.python.org/issue25750