[issue28569] mock.attach_mock should work with any return value of patch()

2016-11-14 Thread Andrey Fedorov
Andrey Fedorov added the comment: Here's the full extension of the example from documentation that doesn't seem to handle classes and functions consistently: import mock patches = { 'requests_get': 'requests.get', 'mymodule_Class1&#

[issue28569] mock.attach_mock should work with any return value of patch()

2016-11-11 Thread Andrey Fedorov
Andrey Fedorov added the comment: To clarify, this is how I would expect these two functions to work together "out of the box" patches = { 'requests_get': 'requests.get', ... } root_mock = mock.Mock() for name, path in patches.items(): m = m

[issue28569] mock.attach_mock should work with any return value of patch()

2016-11-11 Thread Andrey Fedorov
Andrey Fedorov added the comment: There's some vagueness on how this is implemented, but I would prefer manager.attach_mock to also work with whatever the return value of patch() is. On Fri, Nov 11, 2016 at 12:08 PM, Syed Suhail Ahmed wrote: > > Syed Suhail Ahmed added the comm

[issue28569] mock.attach_mock should work with any return value of patch()

2016-10-31 Thread Andrey Fedorov
Changes by Andrey Fedorov : -- title: mock.attach_mock should work with return value of patch() -> mock.attach_mock should work with any return value of patch() ___ Python tracker <http://bugs.python.org/issu

[issue28569] mock.attach_mock should work with return value of patch()

2016-10-31 Thread Andrey Fedorov
New submission from Andrey Fedorov: The attach_mock in the following code sample fails silently: >>> from mock import patch, Mock >>> p = patch('requests.get', autospec=True) >>> manager = Mock() >>> manager.attach_mock(p.st