Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b40a220

Browse files
committed
#17539: fix MagicMock example. Patch by Berker Peksag.
1 parent 1b14592 commit b40a220

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Doc/library/unittest.mock-examples.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,11 @@ with.
324324
...
325325
>>> test()
326326

327-
If you are patching a module (including `__builtin__`) then use `patch`
327+
If you are patching a module (including :mod:`builtins`) then use `patch`
328328
instead of `patch.object`:
329329

330-
>>> mock = MagicMock(return_value = sentinel.file_handle)
331-
>>> with patch('__builtin__.open', mock):
330+
>>> mock = MagicMock(return_value=sentinel.file_handle)
331+
>>> with patch('builtins.open', mock):
332332
... handle = open('filename', 'r')
333333
...
334334
>>> mock.assert_called_with('filename', 'r')

0 commit comments

Comments
 (0)