-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-43478: Restrict use of Mock objects as specs #25326
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
|
Can you use blurb or https://blurb-it.herokuapp.com/ to add a news entry? |
|
As noted in one of the commits, this uncovers a bug in an existing test related to https://bugs.python.org/issue37251. Not sure whether to file another bug but the fix should probably be backported as far as 3.8 if, indeed, the tested behavior was intended. |
|
Sorry, @msuozzo and @gpshead, I could not cleanly backport this to |
|
Sorry @msuozzo and @gpshead, I had trouble checking out the |
|
Lets not rush the 3.9 and 3.8 backport PRs anyways (manual intervention required anyways); let this ship in 3.10b1 (May) and see if anyone pipes up. |
|
Honestly not a fan of merging a PR which adds a skip around a test. @voidspace / @lisroach / @tirkarthi : thoughts? |
|
In general, I agree, a skip or deletion of an existing test always requires extra attention. That test was apparently not-quite-right, this PR exposed that problem which had been hidden. https://bugs.python.org/issue37251 has been reopened which seems like a better place to untangle that than in this merged PR comment thread. |
|
Right, but I would have preferred to see that bug resolved before this PR was merged. Are there other examples of skipped tests like this in cpython or has this merge just set a bad precedent? |
|
There was an error on the travis CI doc build: Is likely related to the NEWS entry. Apparently is not valid resT or something similar. |
Fixed by #25335 |
I found a few disabled tests in the repo so I figured it wasn't a problem. Ex. https://github.com/python/cpython/blob/master/Lib/test/test_pydoc.py#L1013 Still, I think this is the preferable way to order the changes: A test that provides a false impression of some functionality should not remain unchanged once it's discovered. At the same time, a broken test should not block progress elsewhere in the codebase. Fixing forward in this PR or in another one would have required more/longer discussion since it would represent a non-trivial change in behavior. This discussion would be fundamentally unrelated to this PR. As such, I think temporarily annotating the test with its functional status (i.e. that it's broken) and reopening the issue causes the least obstruction while still moving towards addressing the issue. |
Normally this is done in a separate PR with an explanation of what is broken and why we are ignoring it. In this case, unfortunately, is not clear what's broken as the comment redirects to the entire discussion. Also, not only the test is ignored but is also modified from to At the very least, I would suggest documenting in the test exactly what is broken, but ideally, it should be either fixed or removed. Having code that never runs is not a good long term idea. |
I'm afraid the example you cite is exactly why this ends up being a bad idea: I've highlighted your "temporarily annotating" above as the three skips in In this case, it's slightly worse as the backport of mock has code coverage checks, which means this then means you've shunted work onto me that I'll have to figure out before I can do a backport release. |
@pablogsal yeah I think you're right. My intention was to revise the test to perform the check that was actually intended so that it might be easier to revise when addressed. Still, I do think that sort of change could have been left for a separate PR.
Definitely.
@cjw296 I think this is a different situation. Realistically, there just needs to be a decision about whether
I'm not familiar with the code coverage checks to which you're referring. Are there coverage checks on the test code itself that skipping will cause to regress? If not, the test in question actually covered no code since it's only assertion was itself mocked out so I wouldn't expect this to be an issue. |
|
#25347 should fix the |
|
Does this still need backport to 3.8 and 3.9? If not, please remove the labels. |
Follow-on to python#25326 This covers cases where mock objects are passed directly to spec.
Follow-on to #25326 This covers cases where mock objects are passed directly to spec.
|
So, 1.5yrs later and this skipped test is still here, and now going to cause coverage problems in the backport :-( |
|
@msuozzo - as the author of the problematic skip, you're also welcome to fix it. In the absence of anything, your earlier statement: "Realistically, there just needs to be a decision about whether create_autospec behaves as indicated in the test (i.e. requires a fix) or doesn't (i.e. the test can be removed)." - by skipping that test, you've basically implicitly chosen the second option, so if this ends up blocking me, I'll just remove it. |
|
Removing the test or leaving the skip in place are both fine. If you can find anyone willing to review #25347 it'll fix it or re-add the test. I suspect that PR is "good" but there are some open questions on it and it isn't immediately obvious to me if they are relevant. |
Remove skipped test. See discussion on python/cpython#25326. Fix is apparently here, but no-one is confident to review and land: python/cpython#25347. Backports: 984894a9a25c0f8298565b0c0c2e1f41917e4f88 Signed-off-by: Chris Withers <[email protected]>
Follow-on to python/cpython#25326 This covers cases where mock objects are passed directly to spec. Backports: 6394e981adaca2c0daa36c8701611e250d74024c Signed-off-by: Chris Withers <[email protected]>
Remove skipped test. See discussion on python/cpython#25326. Fix is apparently here, but no-one is confident to review and land: python/cpython#25347. Backports: 984894a9a25c0f8298565b0c0c2e1f41917e4f88 Signed-off-by: Chris Withers <[email protected]>
Follow-on to python/cpython#25326 This covers cases where mock objects are passed directly to spec. Backports: 6394e981adaca2c0daa36c8701611e250d74024c Signed-off-by: Chris Withers <[email protected]>
See discussion on python/cpython#25326. Fix is apparently here, but no-one is confident to review and land: python/cpython#25347.
https://bugs.python.org/issue43478