diff options
author | Vlastimil Zíma <ziima@users.noreply.github.com> | 2024-07-18 13:57:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-18 13:57:21 (GMT) |
commit | 94e6644584d9cb08a4edcd1027e288386184816b (patch) | |
tree | 60535f31d8ff0b30726da30e7900d27b5af50f7e | |
parent | cecaceea31f32f01b5617989e3dc8b2077f53f89 (diff) | |
download | cpython-94e6644584d9cb08a4edcd1027e288386184816b.zip cpython-94e6644584d9cb08a4edcd1027e288386184816b.tar.gz cpython-94e6644584d9cb08a4edcd1027e288386184816b.tar.bz2 |
gh-65453: Docs - clarify AttributeError behaviour on PropertyMock (GH-121666)
Fixed at EuroPython 24 sprints.
-rw-r--r-- | Doc/library/unittest.mock.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index 01206e0..757277e 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -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) |