gh-65453: Docs - clarify AttributeError behaviour on PropertyMock (GH-121666)

Fixed at EuroPython 24 sprints.
This commit is contained in:
Vlastimil Zíma 2024-07-18 15:57:21 +02:00 committed by GitHub
parent cecaceea31
commit 94e6644584
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 0 deletions

View File

@ -860,6 +860,20 @@ object::
3
>>> p.assert_called_once_with()
.. caution::
If an :exc:`AttributeError` is raised by :class:`PropertyMock`,
it will be interpreted as a missing descriptor and
:meth:`~object.__getattr__` will be called on the parent mock::
>>> m = MagicMock()
>>> no_attribute = PropertyMock(side_effect=AttributeError)
>>> type(m).my_property = no_attribute
>>> m.my_property
<MagicMock name='mock.my_property' id='140165240345424'>
See :meth:`~object.__getattr__` for details.
.. class:: AsyncMock(spec=None, side_effect=None, return_value=DEFAULT, wraps=None, name=None, spec_set=None, unsafe=False, **kwargs)