diff options
author | Rémi Lapeyre <remi.lapeyre@henki.fr> | 2019-05-07 10:48:36 (GMT) |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2019-05-07 10:48:36 (GMT) |
commit | 11a8832c98b3db78727312154dd1d3ba76d639ec (patch) | |
tree | 9b40898ae686280ee7ea0d672c69f292f04a9c23 /Lib/unittest/test | |
parent | ad4ed872415d00fcdfaa52a08108ec752b115000 (diff) | |
download | cpython-11a8832c98b3db78727312154dd1d3ba76d639ec.zip cpython-11a8832c98b3db78727312154dd1d3ba76d639ec.tar.gz cpython-11a8832c98b3db78727312154dd1d3ba76d639ec.tar.bz2 |
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>
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r-- | Lib/unittest/test/testmock/testwith.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/unittest/test/testmock/testwith.py b/Lib/unittest/test/testmock/testwith.py index 37100b8..5172c22 100644 --- a/Lib/unittest/test/testmock/testwith.py +++ b/Lib/unittest/test/testmock/testwith.py @@ -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): |