mirror of
https://github.com/python/cpython.git
synced 2025-09-28 11:15:17 +00:00
[3.12] Link to the glossary for "magic methods" in `MagicMock
` (GH-111292) (#114002)
Link to the glossary for "magic methods" in ``MagicMock`` (GH-111292)
The MagicMock documentation mentions magic methods several times without
actually pointing to the term in the glossary. This can be helpful for
people to fully understand what those magic methods are.
(cherry picked from commit e97da8677f
)
Co-authored-by: Pierre Equoy <pierre.equoy@canonical.com>
This commit is contained in:
parent
27f7f3712f
commit
b9e15bef82
1 changed files with 4 additions and 4 deletions
|
@ -1960,8 +1960,8 @@ Mocking Magic Methods
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
:class:`Mock` supports mocking the Python protocol methods, also known as
|
:class:`Mock` supports mocking the Python protocol methods, also known as
|
||||||
"magic methods". This allows mock objects to replace containers or other
|
:term:`"magic methods" <magic method>`. This allows mock objects to replace
|
||||||
objects that implement Python protocols.
|
containers or other objects that implement Python protocols.
|
||||||
|
|
||||||
Because magic methods are looked up differently from normal methods [#]_, this
|
Because magic methods are looked up differently from normal methods [#]_, this
|
||||||
support has been specially implemented. This means that only specific magic
|
support has been specially implemented. This means that only specific magic
|
||||||
|
@ -2059,8 +2059,8 @@ There are two ``MagicMock`` variants: :class:`MagicMock` and :class:`NonCallable
|
||||||
.. class:: MagicMock(*args, **kw)
|
.. class:: MagicMock(*args, **kw)
|
||||||
|
|
||||||
``MagicMock`` is a subclass of :class:`Mock` with default implementations
|
``MagicMock`` is a subclass of :class:`Mock` with default implementations
|
||||||
of most of the magic methods. You can use ``MagicMock`` without having to
|
of most of the :term:`magic methods <magic method>`. You can use
|
||||||
configure the magic methods yourself.
|
``MagicMock`` without having to configure the magic methods yourself.
|
||||||
|
|
||||||
The constructor parameters have the same meaning as for :class:`Mock`.
|
The constructor parameters have the same meaning as for :class:`Mock`.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue