From: Ezio Melotti Date: Sat, 30 Mar 2013 03:55:52 +0000 (+0200) Subject: #17539: fix MagicMock example. Patch by Berker Peksag. X-Git-Tag: v3.3.2~190 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b40a2203adff6511afc65fe885816636e135c935;p=thirdparty%2FPython%2Fcpython.git #17539: fix MagicMock example. Patch by Berker Peksag. --- diff --git a/Doc/library/unittest.mock-examples.rst b/Doc/library/unittest.mock-examples.rst index 0d136eb44849..d7d697d65099 100644 --- a/Doc/library/unittest.mock-examples.rst +++ b/Doc/library/unittest.mock-examples.rst @@ -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')