mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
bpo-31855: unittest.mock.mock_open() results now respects the argument of read([size]) (GH-11521)
unittest.mock.mock_open() results now respects the argument of read([size]) Co-Authored-By: remilapeyre <remi.lapeyre@henki.fr>
This commit is contained in:
parent
ad4ed87241
commit
11a8832c98
3 changed files with 21 additions and 25 deletions
|
@ -283,7 +283,12 @@ class TestMockOpen(unittest.TestCase):
|
|||
# for mocks returned by mock_open
|
||||
some_data = 'foo\nbar\nbaz'
|
||||
mock = mock_open(read_data=some_data)
|
||||
self.assertEqual(mock().read(10), some_data)
|
||||
self.assertEqual(mock().read(10), some_data[:10])
|
||||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue