* Mark functions that will never be called with # pragma: no cover
* Fix testpatch.PatchTest.test_exit_idempotent
.stop() and __exit__ have subtly different code paths, so to really test __exit__ idempotency, we need to call it specifically twice.
class WithMethod:
a: int
def b(self) -> int:
- return 1
+ return 1 # pragma: no cover
for mock in [
create_autospec(WithMethod, instance=True),
passed to the wrapped object and the return_value is returned instead.
"""
def my_func():
- return None
+ return None # pragma: no cover
func_mock = create_autospec(spec=my_func, wraps=my_func)
return_value = "explicit return value"
func_mock.return_value = return_value
def test_exit_idempotent(self):
patcher = patch(foo_name, 'bar', 3)
with patcher:
- patcher.stop()
+ patcher.__exit__(None, None, None)
def test_second_start_failure(self):