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-31855: unittest.mock.mock_open() results now respects the argument of read([size]) #11521

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for successive reads
  • Loading branch information
Rémi Lapeyre committed May 6, 2019
commit ee7d67ae261d43f7065f3ef7a89857f6e9528930
5 changes: 5 additions & 0 deletions Lib/unittest/test/testmock/testwith.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ def test_mock_open_read_with_argument(self):
some_data = 'foo\nbar\nbaz'
mock = mock_open(read_data=some_data)
self.assertEqual(mock().read(10), some_data[:10])
remilapeyre marked this conversation as resolved.
Show resolved Hide resolved
self.assertEqual(mock().read(10), some_data[:10])

f = mock()
self.assertEqual(f.read(10), some_data[:10])
self.assertEqual(f.read(10), some_data[10:])


def test_interleaved_reads(self):
Expand Down