cpython/Lib/unittest/test/testmock
Mario Corchero f05df0a4b6 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.
2018-12-08 11:25:02 +00:00
..
__init__.py
__main__.py
support.py Remove unused function in testmock/support.py (GH-10975) 2018-12-06 17:05:46 +00:00
testcallable.py bpo-35357: Add _mock_ prefix to name/parent/from_kall attributes of _Call/_MagicProxy. (#10873) 2018-12-04 09:08:45 +00:00
testhelpers.py bpo-35226: Fix equality for nested unittest.mock.call objects. (#10555) 2018-12-03 21:31:37 +00:00
testmagicmethods.py bpo-35022: unittest.mock.MagicMock now also supports __fspath__ (GH-9960) 2018-10-25 23:48:58 +02:00
testmock.py bpo-35330: Don't call the wrapped object if side_effect is set (GH10973) 2018-12-08 11:25:02 +00:00
testpatch.py bpo-33747: Avoid mutating the global sys.modules dict in unittest.mock tests (GH-8520) 2018-12-07 15:30:42 -08:00
testsealable.py bpo-30541: Add new method to seal mocks (GH61923) 2017-10-17 04:35:11 -07:00
testsentinel.py Issue #20804: The unittest.mock.sentinel attributes now preserve their 2017-01-11 20:13:03 +02:00
testwith.py bpo-32933: Implement __iter__ method on mock_open() (GH-5974) 2018-09-13 01:21:16 +03:00