-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
gh-70280: allow using custom sys.displayhook's with doctest #25651
Conversation
test_ttk_guionly() failure unrelated to the PR. |
@tim-one, you are listed as an expert for this module, thus I'm ask you for review. The author of the reverted patch is ok with the change, see the bug thread. I think, it's an easy thing to decide if this can be accepted or not. I would prefer this in 3.10, if possible. |
This PR is stale because it has been open for 30 days with no activity. |
@ezio-melotti, you are listed as an expert for testing in the devguide, could you review this little PR? (It seems the doctest module lacks a maintainer.) |
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.
Good call.
(FYI, I've updated the PR description with gh numbers iso. bpo numbers.) |
It isn't obviously clear to me if Tim's #70280 (comment) approved or disapproved of this change. I have no opinion about it, but I'd appreciate a +1 from one or two other core devs before accepting this. |
Lib/test/test_doctest.py
Outdated
>>> with patch('sys.displayhook', sys.__displayhook__): | ||
... r = doctest.DocTestRunner(verbose=False).run(test) |
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.
Instead of "fixing" the displayhook
here with unittest.mock.patch
, the behavior and this workaround should be documented:
- describe that doctest now honors custom
displayhook
s - add a
.. versionchanged
to indicate the change in behavior - suggest
unittest.mock.patch
as a way to restore thedisplayhook
while running the doctests - suggest
testsetup
/testcleanup
as another option
In addition, since this is a change in behavior, it might be better to add a FutureWarning
and actually implement the change after 1-2 releases.
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.
@ezio-melotti , I have made the requested changes; please review again.
I'm not so sure which is a right place for the versionchanged stuff. Right now it's the changed method. Let me know it it's ok or suggesting patch/testsetup/etc is required (I find this too trivial to add, after all - changing the sys.displayhook is very well documented).
Let me also know if the two-step process with the FutureWarning is required: I'll create another PR with a warning (actual change will be postponed for 3.13, it's correct?). So far, the current state wasn't documented and it seems to be rather a bug then a compatibility breaker...
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 |
Thanks for making the requested changes! @ezio-melotti: please review the changes made to this pull request. |
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.
It does not add support for testing examples with a customized sys.displayhook
value, as claimed. It unconditionally changes the current behavior. It breaks the code that sets sys.displayhook
outside of tests, and it leaks sys.displayhook
explicitly set in a doctest.
@serhiy-storchaka, that's the point.
In fact, it tests the code that sets sys.displayhook outside of tests, unless I misunderstood you. In last commits I've added also a test for changing the sys.displayhook value inside of doctests. |
@erlend-aasland, maybe you could redo your review after recent changes? Core devs seems to be inactive for month and I would appreciate any feedback on how well I addressed their review comments. |
My stance is still the same as before:
Although I have the power to approve and merge this, I of course won't do such a thing. I don't see any loud and clear +1 from any other core dev, hence I'm more aligned to close both this PR and the linked issue. I'll unsubscribe from this and leave it for Ezio and Serhiy (or any other core dev who want to pick this up). |
This reverts patch from https://bugs.python.org/issue8048
Feel free to take this over. |
This reverts patch from gh-52296.