Skip to content
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

Merged
merged 13 commits into from Sep 12, 2018
Merged

bpo-32933: Implement dunder iter method on mock_open #5974

merged 13 commits into from Sep 12, 2018

Conversation

TonyFlury
Copy link
Contributor

@TonyFlury TonyFlury commented Mar 4, 2018

@the-knights-who-say-ni
Copy link

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!

@TonyFlury
Copy link
Contributor Author

I have signed the CLA - 11:10 GMT 4th March 2018 - not sure how often the bot runs

Copy link
Contributor

@gst gst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@1st1 1st1 left a 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.

while True:
yield handle.readline.return_value
for line in _state[0]:
yield line
Copy link
Member

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')
Copy link
Member

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.

@bedevere-bot
Copy link

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.

@TonyFlury
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@1st1: please review the changes made to this pull request.

@1st1
Copy link
Member

1st1 commented Apr 30, 2018

Please add a NEWS entry (using the blurb tool). CI needs to be fixed too before we can merge this.

@TonyFlury
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@1st1: please review the changes made to this pull request.

TonyFlury and others added 6 commits July 9, 2018 17:46
Style changes to be consistent with rest of file
Added extra readline call to check empty string returned after file is consumed.
@TonyFlury
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@berkerpeksag, @1st1: please review the changes made to this pull request.

@TonyFlury
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@berkerpeksag, @1st1: please review the changes made to this pull request.

@berkerpeksag
Copy link
Member

Thanks!

@miss-islington
Copy link
Contributor

Thanks @TonyFlury for the PR, and @berkerpeksag for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-9311 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 14, 2018
(cherry picked from commit 2087023)

Co-authored-by: Tony Flury <anthony.flury@btinternet.com>
berkerpeksag pushed a commit that referenced this pull request Sep 14, 2018
(cherry picked from commit 2087023)

Co-authored-by: Tony Flury <anthony.flury@btinternet.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants