[issue42556] unittest.mock.patch() cannot properly mock methods

2020-12-16 Thread Mario Corchero
Mario Corchero added the comment: Right, I believe this is indeed broken. This code: ``` class A: def m(self, a=None): pass from unittest import mock with mock.patch.object(A, "m", autospec=True): A.m.side_effect = print A().m(1) ``` prints: <__main__.A object at 0x7f69cc7dc6a0>

[issue42556] unittest.mock.patch() cannot properly mock methods

2020-12-03 Thread Pierre Ossman
New submission from Pierre Ossman : unittest.mock.patch() as it currently works cannot properly mock a method as it currently replaces it with something more mimicking a function. I.e. the descriptor magic that includes "self" isn't properly set up. In most cases this doesn't really matter, b