summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2020-01-25 10:53:54 (GMT)
committerChris Withers <chris@withers.org>2020-01-25 10:53:54 (GMT)
commit40c080934b3d49311209b1cb690c2ea1e04df7e7 (patch)
tree57229d44d35b10601bdfa87cc725122041a27da5
parent62865f4532094017a9b780b704686ca9734bc329 (diff)
downloadcpython-40c080934b3d49311209b1cb690c2ea1e04df7e7.zip
cpython-40c080934b3d49311209b1cb690c2ea1e04df7e7.tar.gz
cpython-40c080934b3d49311209b1cb690c2ea1e04df7e7.tar.bz2
bpo-37955: correct mock.patch docs with respect to the returned type (GH-15521)
-rw-r--r--Doc/library/unittest.mock.rst3
-rw-r--r--Lib/unittest/mock.py3
2 files changed, 4 insertions, 2 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index 8394304..515bdd0 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 047ae7c..a97542a 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.