summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorMario Corchero <mariocj89@gmail.com>2018-12-08 11:25:02 (GMT)
committerChris Withers <chris@withers.org>2018-12-08 11:25:02 (GMT)
commitf05df0a4b679d0acfd0b1fe6187ba2d553b37afa (patch)
tree5a048fb3c7aef3ffebb5a955ae2259823d0b1d8f /Misc
parent3cf74384b53b998fa846dc2590cedf9ad2a0d5fd (diff)
downloadcpython-f05df0a4b679d0acfd0b1fe6187ba2d553b37afa.zip
cpython-f05df0a4b679d0acfd0b1fe6187ba2d553b37afa.tar.gz
cpython-f05df0a4b679d0acfd0b1fe6187ba2d553b37afa.tar.bz2
bpo-35330: Don't call the wrapped object if `side_effect` is set (GH10973)
* tests: Further validate `wraps` functionality in `unittest.mock.Mock` Add more tests to validate how `wraps` interacts with other features of mocks. * Don't call the wrapped object if `side_effect` is set When a object is wrapped using `Mock(wraps=...)`, if an user sets a `side_effect` in one of their methods, return the value of `side_effect` and don't call the original object. * Refactor what to be called on `mock_call` When a `Mock` is called, it should return looking up in the following order: `side_effect`, `return_value`, `wraps`. If any of the first two return `mock.DEFAULT`, lookup in the next option. It makes no sense to check for `wraps` returning default, as it is supposed to be the original implementation and there is nothing to fallback to.
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS.d/next/Library/2018-12-06-00-43-13.bpo-35330.abB4BN.rst4
1 files changed, 4 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2018-12-06-00-43-13.bpo-35330.abB4BN.rst b/Misc/NEWS.d/next/Library/2018-12-06-00-43-13.bpo-35330.abB4BN.rst
new file mode 100644
index 0000000..24d0ab8
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-12-06-00-43-13.bpo-35330.abB4BN.rst
@@ -0,0 +1,4 @@
+When a :class:`Mock` instance was used to wrap an object, if `side_effect`
+is used in one of the mocks of it methods, don't call the original
+implementation and return the result of using the side effect the same way
+that it is done with return_value.