This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calls to magic methods do not appear in :attr:`~Mock.method_calls`, but they
Calls to special methods do not appear in :attr:`~Mock.method_calls`, but they
are recorded in :attr:`~Mock.mock_calls`.
.. note::
If you use the *spec* keyword argument to create a mock then attempting to
set a magic method that isn't in the spec will raise an :exc:`AttributeError`.
set a special method that isn't in the spec will raise an :exc:`AttributeError`.
The full list of supported magic methods is:
The full list of supported special methods is:
* ``__hash__``, ``__sizeof__``, ``__repr__`` and ``__str__``
* ``__dir__``, ``__format__`` and ``__subclasses__``
Expand Down
Expand Up
@@ -1687,21 +1687,21 @@ by mock, can't be set dynamically, or can cause problems:
Magic Mock
~~~~~~~~~~
MagicMock
~~~~~~~~~
There are two ``MagicMock`` variants: :class:`MagicMock` and :class:`NonCallableMagicMock`.
.. class:: MagicMock(*args, **kw)
``MagicMock`` is a subclass of :class:`Mock` with default implementations
of most of the magic methods. You can use ``MagicMock`` without having to
configure the magic methods yourself.
of most of the special methods. You can use ``MagicMock`` without having to
configure the special methods yourself.
The constructor parameters have the same meaning as for :class:`Mock`.
If you use the *spec* or *spec_set* arguments then *only* magic methods
If you use the *spec* or *spec_set* arguments then *only* special methods
that exist in the spec will be created.
Expand All
@@ -1713,7 +1713,7 @@ There are two ``MagicMock`` variants: :class:`MagicMock` and :class:`NonCallable
:class:`MagicMock`, with the exception of *return_value* and
*side_effect* which have no meaning on a non-callable mock.
The magic methods are setup with :class:`MagicMock` objects, so you can configure them
The special methods are setup with :class:`MagicMock` objects, so you can configure them
and use them in the usual way:
>>> mock = MagicMock()
Expand Down
Expand Up
@@ -1793,10 +1793,10 @@ it and subsequent iterations will result in an empty list:
>>> list(mock)
[]
``MagicMock`` has all of the supported magic methods configured except for some
``MagicMock`` has all of the supported special methods configured except for some
of the obscure and obsolete ones. You can still set these up if you want.
Magic methods that are supported but not setup by default in ``MagicMock`` are:
Special methods that are supported but not setup by default in ``MagicMock`` are:
* ``__subclasses__``
* ``__dir__``
Expand All
@@ -1809,7 +1809,7 @@ Magic methods that are supported but not setup by default in ``MagicMock`` are:
.. [#] Magic methods *should* be looked up on the class rather than the
.. [#] Special methods *should* be looked up on the class rather than the
instance. Different versions of Python are inconsistent about applying this
rule. The supported protocol methods should work with all supported versions
of Python.
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bpo-33825: Change mentions of "magic" attributes to "special" #7608
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
bpo-33825: Change mentions of "magic" attributes to "special" #7608
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing