Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Doc/library/unittest.mock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,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.
to construct a :class:`AsyncMock` if the patched object is an async function,
Comment thread
phsilva marked this conversation as resolved.
Outdated
to :class:`MagicMock` otherwise or to *new_callable* if specified.

``patch.dict(...)``, ``patch.multiple(...)`` and ``patch.object(...)`` are
available for alternate use-cases.
Expand Down
3 changes: 2 additions & 1 deletion Lib/unittest/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,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.
to construct a `AsyncMock` if the patched object is an async function,
to `MagicMock` otherwise or to `new_callable` if specified.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way we could not have this text duplicated between mock.py and mock.rst?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am new to Python docs, but as far as I looked around there is a lot of duplication between .rst and .py in many modules, will need to ask around about if there is another way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes this a more substantial PR, but Sphinx autodoc should be able to pull in the .py's docstrings. Not sure if autodoc is enabled for the CPython docs, that would be some more digging on your part :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will take a look into it, but it looks like all modules actually repeats docs in Doc and in Lib, will ask around why.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did the asking around go?


`patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
available for alternate use-cases.
Expand Down