[issue41296] unittest.mock: patched mocks do not propagate calls to parent when set via setattr

2020-07-14 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bugs-list

[issue41296] unittest.mock: patched mocks do not propagate calls to parent when set via setattr

2020-07-14 Thread thinkingmachin6
thinkingmachin6 added the comment: This appears to be a case of RTFM (https://docs.python.org/3/library/unittest.mock.html#attaching-mocks-as-attributes). For anybody that comes across this, the short answer is use `attach_mock()` instead of plain attribute-setting. -- resolution:

[issue41296] unittest.mock: patched mocks do not propagate calls to parent when set via setattr

2020-07-14 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +xtreak ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue41296] unittest.mock: patched mocks do not propagate calls to parent when set via setattr

2020-07-14 Thread john passaro
New submission from john passaro : I expected the following code to print True: import os from unittest.mock import call, Mock, patch parent = Mock() parent.getenv = patch('os.getenv') with parent.getenv: os.getenv('FOO', 'bar') expected = [call.getenv('FOO', 'bar')] print(expected,