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 rbcollins
Recipients clarkbreyman, rbcollins
Date 2016-06-03.21:04:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464987872.51.0.666150388947.issue27197@psf.upfronthosting.co.za>
In-reply-to
Content
So its a feature of mock that it can mock a module that doesn't exist. And the semantics of the import system are designed to be very cheap when a module is already imported - so when 'patchbug.a' is in sys.modules, import will correctly return it rather than going out to the import path to find if its the same thing.

We could possibly have an opt-in check on mock.patch to require that the thing being patched exists, but it would have to be opt-in as so many cases are dealing with optional or pretend instances. I'm not super keen on that though.

This is perhaps worth calling out in the docs to avoid confusion.
History
Date User Action Args
2016-06-03 21:04:32rbcollinssetrecipients: + rbcollins, clarkbreyman
2016-06-03 21:04:32rbcollinssetmessageid: <1464987872.51.0.666150388947.issue27197@psf.upfronthosting.co.za>
2016-06-03 21:04:32rbcollinslinkissue27197 messages
2016-06-03 21:04:32rbcollinscreate