diff options
author | Michael Foord <michael@voidspace.org.uk> | 2012-04-13 15:57:22 (GMT) |
---|---|---|
committer | Michael Foord <michael@voidspace.org.uk> | 2012-04-13 15:57:22 (GMT) |
commit | c287062fcf8b891db3b982e628cb297165b766e2 (patch) | |
tree | e50e3acde7c9caa8583794e2c19916cd1422c28f /Doc | |
parent | 633b32a7fa7ba57dbb3d7fd6fbda00595cc135c8 (diff) | |
download | cpython-c287062fcf8b891db3b982e628cb297165b766e2.zip cpython-c287062fcf8b891db3b982e628cb297165b766e2.tar.gz cpython-c287062fcf8b891db3b982e628cb297165b766e2.tar.bz2 |
unittest.mock.PropertyMock return value and attributes are now standard MagicMocks
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/unittest.mock.rst | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index df1c41f..f00d29f 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -712,6 +712,17 @@ have to create a dictionary and unpack it using `**`: >>> mock_foo.mock_calls [call(), call(6)] +Because of the way mock attributes are stored you can't directly attach a +`PropertyMock` to a mock object. Instead you can attach it to the mock type +object:: + + >>> m = MagicMock() + >>> p = PropertyMock(return_value=3) + >>> type(m).foo = p + >>> m.foo + 3 + >>> p.assert_called_once_with() + Calling ~~~~~~~ |