cpython/Lib/unittest
Miss Islington (bot) ee2c5a8e2d 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 f05df0a4b6)

Co-authored-by: Mario Corchero <mariocj89@gmail.com>
2018-12-08 11:47:01 +00:00
..
test bpo-35330: Don't call the wrapped object if `side_effect` is set (GH11035) 2018-12-08 11:47:01 +00:00
__init__.py Issue #28303: Fix grammar in unittest.__doc__, patch by Shlomi Fish 2016-09-28 17:28:41 +03:00
__main__.py bpo-29919: Remove unused imports found by pyflakes (#137) 2017-03-27 16:05:26 +02:00
case.py bpo-34900: Make TestCase.debug() work with subtests (GH-9707) 2018-10-12 14:07:01 +03:00
loader.py bpo-32071: Fix regression and add What's New entry (#4589) 2017-11-28 20:40:44 +01:00
main.py bpo-32071: Add unittest -k option (#4496) 2017-11-25 16:23:52 +01:00
mock.py bpo-35330: Don't call the wrapped object if `side_effect` is set (GH11035) 2018-12-08 11:47:01 +00:00
result.py Issue #27076: Doc, comment and tests spelling fixes 2016-05-26 05:35:26 +00:00
runner.py #27364: fix "incorrect" uses of escape character in the stdlib. 2016-09-08 13:59:53 -04:00
signals.py Closes issue 15505. unittest.installHandler and non-callable signal handlers. 2013-01-29 23:07:57 +00:00
suite.py Issue #27171: Fix typos in documentation, comments, and test function names 2016-06-02 10:07:09 +00:00
util.py bpo-32360: unittest.util: Use Counter instead of custom count function (GH-4994) 2018-01-24 16:49:58 +09:00