summaryrefslogtreecommitdiff
path: root/Lib/unittest/test/testmock/testwith.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-05-07 05:34:48 -0700
committerChris Withers <chris@withers.org>2019-05-07 13:34:48 +0100
commita6516f89aa0f416c7514ac364bb48ac7d1455487 (patch)
tree9b7eaeca6c96b2266077d6a754b571fd643b1a3d /Lib/unittest/test/testmock/testwith.py
parentffa29b5aca1aaeae46af2582c401ef0ed20d4153 (diff)
downloadcpython-git-a6516f89aa0f416c7514ac364bb48ac7d1455487.tar.gz
bpo-31855: unittest.mock.mock_open() results now respects the argument of read([size]) (GH-11521) (#13152)
unittest.mock.mock_open() results now respects the argument of read([size]) Co-Authored-By: remilapeyre <remi.lapeyre@henki.fr> (cherry picked from commit 11a8832c98b3db78727312154dd1d3ba76d639ec) Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
Diffstat (limited to 'Lib/unittest/test/testmock/testwith.py')
-rw-r--r--Lib/unittest/test/testmock/testwith.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/unittest/test/testmock/testwith.py b/Lib/unittest/test/testmock/testwith.py
index ec4e540dcf..0fa42e18ec 100644
--- a/Lib/unittest/test/testmock/testwith.py
+++ b/Lib/unittest/test/testmock/testwith.py
@@ -286,7 +286,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):