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-32933: Implement dunder iter method on mock_open #5974
Conversation
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 our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
I have signed the CLA - 11:10 GMT 4th March 2018 - not sure how often the bot runs |
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.
LGTM
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.
The PR looks OK overall. The code formatting needs to be fixed in one place, and I also suggest to make code a bit more DRY, which should improve its readability.
Lib/unittest/mock.py
Outdated
while True: | ||
yield handle.readline.return_value | ||
for line in _state[0]: | ||
yield line |
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.
Can you refactor def _readline_side_effect():
to use this new method for clarity:
def _readline_side_effect():
yield from _iter_side_effect()
while True:
yield type(read_data)()
@@ -1450,6 +1450,14 @@ def test_mock_open_reuse_issue_21750(self): | |||
f2_data = f2.read() | |||
self.assertEqual(f1_data, f2_data) | |||
|
|||
def test_mock_open_dunder_iter_issue_32933(self): | |||
mocked_open = mock.mock_open(read_data='Remarkable Bird\nThe Norwegian Blue\nBeautiful Plumage') |
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.
This line is too long: trim your code to fit in 79 characters.
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! @1st1: please review the changes made to this pull request. |
Please add a NEWS entry (using the |
…ate to official documentation.
I have made the requested changes; please review again. |
Thanks for making the requested changes! @1st1: please review the changes made to this pull request. |
Style changes to be consistent with rest of file Added extra readline call to check empty string returned after file is consumed.
I have made the requested changes; please review again |
Thanks for making the requested changes! @berkerpeksag, @1st1: please review the changes made to this pull request. |
I have made the requested changes; please review again |
Thanks for making the requested changes! @berkerpeksag, @1st1: please review the changes made to this pull request. |
Thanks! |
Thanks @TonyFlury for the PR, and @berkerpeksag for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
GH-9311 is a backport of this pull request to the 3.7 branch. |
(cherry picked from commit 2087023) Co-authored-by: Tony Flury <anthony.flury@btinternet.com>
https://bugs.python.org/issue32933