Commit b40a2203 authored by Ezio Melotti's avatar Ezio Melotti

#17539: fix MagicMock example. Patch by Berker Peksag.

parent 1b145927
......@@ -324,11 +324,11 @@ with.
...
>>> test()
If you are patching a module (including `__builtin__`) then use `patch`
If you are patching a module (including :mod:`builtins`) then use `patch`
instead of `patch.object`:
>>> mock = MagicMock(return_value = sentinel.file_handle)
>>> with patch('__builtin__.open', mock):
>>> mock = MagicMock(return_value=sentinel.file_handle)
>>> with patch('builtins.open', mock):
... handle = open('filename', 'r')
...
>>> mock.assert_called_with('filename', 'r')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment