[Python-checkins] bpo-37955: correct mock.patch docs with respect to the returned type (GH-15521)

Chris Withers webhook-mailer at python.org
Sat Jan 25 05:53:58 EST 2020


https://github.com/python/cpython/commit/40c080934b3d49311209b1cb690c2ea1e04df7e7
commit: 40c080934b3d49311209b1cb690c2ea1e04df7e7
branch: master
author: Paulo Henrique Silva <ph.silva at gmail.com>
committer: Chris Withers <chris at withers.org>
date: 2020-01-25T10:53:54Z
summary:

bpo-37955: correct mock.patch docs with respect to the returned type (GH-15521)

files:
M Doc/library/unittest.mock.rst
M Lib/unittest/mock.py

diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index 8394304cfdd9a..515bdd060a198 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -1401,7 +1401,8 @@ patch
     "as"; very useful if :func:`patch` is creating a mock object for you.
 
     :func:`patch` takes arbitrary keyword arguments. These will be passed to
-    the :class:`Mock` (or *new_callable*) on construction.
+    :class:`AsyncMock` if the patched object is asynchronous, to
+    :class:`MagicMock` otherwise or to *new_callable* if specified.
 
     ``patch.dict(...)``, ``patch.multiple(...)`` and ``patch.object(...)`` are
     available for alternate use-cases.
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 047ae7c25599b..a97542a2ddf00 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -1730,7 +1730,8 @@ def patch(
     "as"; very useful if `patch` is creating a mock object for you.
 
     `patch` takes arbitrary keyword arguments. These will be passed to
-    the `Mock` (or `new_callable`) on construction.
+    `AsyncMock` if the patched object is asynchronous, to `MagicMock`
+    otherwise or to `new_callable` if specified.
 
     `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
     available for alternate use-cases.



More information about the Python-checkins mailing list