mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Issue #21750: Further fixup to be styled like other mock APIs.
This commit is contained in:
parent
80e4f30e64
commit
ca647ef60a
4 changed files with 68 additions and 37 deletions
|
|
@ -141,6 +141,7 @@ class TestMockOpen(unittest.TestCase):
|
|||
|
||||
def test_mock_open_context_manager(self):
|
||||
mock = mock_open()
|
||||
handle = mock.return_value
|
||||
with patch('%s.open' % __name__, mock, create=True):
|
||||
with open('foo') as f:
|
||||
f.read()
|
||||
|
|
@ -148,8 +149,7 @@ class TestMockOpen(unittest.TestCase):
|
|||
expected_calls = [call('foo'), call().__enter__(), call().read(),
|
||||
call().__exit__(None, None, None)]
|
||||
self.assertEqual(mock.mock_calls, expected_calls)
|
||||
# mock_open.return_value is no longer static, because
|
||||
# readline support requires that it mutate state
|
||||
self.assertIs(f, handle)
|
||||
|
||||
def test_mock_open_context_manager_multiple_times(self):
|
||||
mock = mock_open()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue