diff options
author | Robert Collins <rbtcollins@hp.com> | 2015-07-24 03:48:20 +1200 |
---|---|---|
committer | Robert Collins <rbtcollins@hp.com> | 2015-07-24 07:20:55 +1200 |
commit | 4292afa83ce217f1b2f492735aa4a03e6b68242f (patch) | |
tree | f98f275561d06fe194ddd7dcf70a3fbd5a292e86 /mock/tests/testwith.py | |
parent | f12f9ddb66a5b46427d9a16231adb688cffaabd0 (diff) | |
download | mock-4292afa83ce217f1b2f492735aa4a03e6b68242f.tar.gz |
Issue #21750: Further fixup to be styled like other mock APIs.
Diffstat (limited to 'mock/tests/testwith.py')
-rw-r--r-- | mock/tests/testwith.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/mock/tests/testwith.py b/mock/tests/testwith.py index 25d706f..b9cfab1 100644 --- a/mock/tests/testwith.py +++ b/mock/tests/testwith.py @@ -156,6 +156,20 @@ class TestMockOpen(unittest.TestCase): self.assertEqual(mock.mock_calls, expected_calls) self.assertIs(f, handle) + def test_mock_open_context_manager_multiple_times(self): + mock = mock_open() + with patch('%s.open' % __name__, mock, create=True): + with open('foo') as f: + f.read() + with open('bar') as f: + f.read() + + expected_calls = [ + call('foo'), call().__enter__(), call().read(), + call().__exit__(None, None, None), + call('bar'), call().__enter__(), call().read(), + call().__exit__(None, None, None)] + self.assertEqual(mock.mock_calls, expected_calls) def test_explicit_mock(self): mock = MagicMock() |