diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-12-08 11:47:01 (GMT) |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2018-12-08 11:47:01 (GMT) |
commit | ee2c5a8e2dcf662048dbcf4e49af9b4aaf81f7d3 (patch) | |
tree | 7d53e06480d41775b76f5b56ec3a59bf19dc441b /PC/python_uwp.cpp | |
parent | 783b794a5e6ea3bbbaba45a18b9e03ac322b3bd4 (diff) | |
download | cpython-ee2c5a8e2dcf662048dbcf4e49af9b4aaf81f7d3.zip cpython-ee2c5a8e2dcf662048dbcf4e49af9b4aaf81f7d3.tar.gz cpython-ee2c5a8e2dcf662048dbcf4e49af9b4aaf81f7d3.tar.bz2 |
bpo-35330: Don't call the wrapped object if `side_effect` is set (GH11035)
* 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.
(cherry picked from commit f05df0a4b679d0acfd0b1fe6187ba2d553b37afa)
Co-authored-by: Mario Corchero <mariocj89@gmail.com>
Diffstat (limited to 'PC/python_uwp.cpp')
0 files changed, 0 insertions, 0 deletions