Skip to content

Commit

Permalink
[3.13] gh-65453: Docs - clarify AttributeError behaviour on PropertyM…
Browse files Browse the repository at this point in the history
…ock (GH-121666) (GH-121968)

Fixed at EuroPython 24 sprints.
(cherry picked from commit 94e6644)

Co-authored-by: Vlastimil Zíma <[email protected]>
  • Loading branch information
miss-islington and ziima authored Jul 19, 2024
1 parent d2caf8b commit 7f63241
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Doc/library/unittest.mock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 7f63241

Please sign in to comment.