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

This commit is contained in:
Ezio Melotti 2013-03-30 05:55:52 +02:00
parent 1b145927d7
commit b40a2203ad

View file

@ -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')