aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/unittest/test/testmock/testmock.py
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2015-07-17 20:08:45 +1200
committerRobert Collins <rbtcollins@hp.com>2015-07-17 20:08:45 +1200
commit5329aaa74bfe48a3be4fcd15d070bacfde682267 (patch)
treedf4df4e19122af73c1a262d2719843b8ef990c87 /Lib/unittest/test/testmock/testmock.py
parent579db160b392404b6dd9608ce5f5bef29a9885a4 (diff)
downloadcpython-5329aaa74bfe48a3be4fcd15d070bacfde682267.tar.gz
cpython-5329aaa74bfe48a3be4fcd15d070bacfde682267.zip
Issue #21750: mock_open.read_data can now be read from each instance, as it
could in Python 3.3.
Diffstat (limited to 'Lib/unittest/test/testmock/testmock.py')
-rw-r--r--Lib/unittest/test/testmock/testmock.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index 4fe63149136..32703e6d7bc 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -1326,6 +1326,11 @@ class MockTest(unittest.TestCase):
self.assertEqual(m.mock_calls, [call.__int__(), call.__float__()])
self.assertEqual(m.method_calls, [])
+ def test_mock_open_reuse_issue_21750(self):
+ mocked_open = mock.mock_open(read_data='data')
+ f1 = mocked_open('a-name')
+ f2 = mocked_open('another-name')
+ self.assertEqual(f1.read(), f2.read())
def test_mock_parents(self):
for Klass in Mock, MagicMock: