This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author anfedorov
Recipients anfedorov, michael.foord
Date 2016-10-31.17:32:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1477935134.31.0.733482108189.issue28569@psf.upfronthosting.co.za>
In-reply-to
Content
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.start(), 'requests_get')
    >>> import requests
    >>> requests.get('https://google.com')
    <MagicMock name='get()' id='4472381392'>
    >>> manager.mock_calls
    []
    >>> p.stop()
    >>> manager.mock_calls
    []

It seems this would be a useful use-case, especially given that this code would work as-expected if 'requests.get' in the second line were replaced with a path to a class.
History
Date User Action Args
2016-10-31 17:32:14anfedorovsetrecipients: + anfedorov, michael.foord
2016-10-31 17:32:14anfedorovsetmessageid: <1477935134.31.0.733482108189.issue28569@psf.upfronthosting.co.za>
2016-10-31 17:32:14anfedorovlinkissue28569 messages
2016-10-31 17:32:13anfedorovcreate