From 40c080934b3d49311209b1cb690c2ea1e04df7e7 Mon Sep 17 00:00:00 2001 From: Paulo Henrique Silva Date: Sat, 25 Jan 2020 07:53:54 -0300 Subject: [PATCH] bpo-37955: correct mock.patch docs with respect to the returned type (GH-15521) --- Doc/library/unittest.mock.rst | 3 ++- Lib/unittest/mock.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index 8394304cfdd..515bdd060a1 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 047ae7c2559..a97542a2ddf 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.