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, shmed
Date 2016-11-14.17:04:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAH3wspmoSGX1M-5LAzMeE21R9M1V7q69fCS3AfD5_mjgL+spyg@mail.gmail.com>
In-reply-to <1479124039.53.0.164992754295.issue28569@psf.upfronthosting.co.za>
Content
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': 'mymodule.Class1'
  }

  root_mock = mock.Mock()
  for name, path in patches.items():
      m = mock.patch(path, autospec=True)
      root_mock.attach_mock(m.start(), name)

  import requests
  import mymodule

  mymodule.Class1('foo')
  requests.get('bar')

  print root_mock.mock_calls
  # [call.mymodule_Class1('foo')]

Does this working as expected make sense, or is there some reason this is
an undesirable API to behave consistently regardless of what's being
patched?
History
Date User Action Args
2016-11-14 17:04:07anfedorovsetrecipients: + anfedorov, michael.foord, shmed
2016-11-14 17:04:07anfedorovlinkissue28569 messages
2016-11-14 17:04:07anfedorovcreate