[issue36834] mock.patch.object does not persist __module__ name for functions

2019-05-07 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: I guess the problem is that to patch 'bar' in foo.bar the signature of bar is taken and then it's evaluated using exec [1] where the function body has _check_sig that checks for the signature during function call. _check_sig has attributes of func c

[issue36834] mock.patch.object does not persist __module__ name for functions

2019-05-07 Thread Sam Park
New submission from Sam Park : The expectation is that the __module__ attribute for a patched function should persist after patching. Minimal test case is attached. Simply run pytest in a venv with the files. Output: def test_zxc(): with mock.patch.object(mymodule, 'asd', side_effect=