[issue27376] Add mock_import method to mock module

2022-04-02 Thread Irit Katriel
Irit Katriel added the comment: Closing as that's where the discussion of 2016 was leaning. Please raise this on python-ideas if you would like to bring it up again. -- nosy: +iritkatriel resolution: -> rejected stage: patch review -> resolved status: open -> closed

[issue27376] Add mock_import method to mock module

2016-09-01 Thread Israel Fruchter
Israel Fruchter added the comment: Some real use cases is needed, like testing a code that behave differently on case of package availability. I think something like patch for modules can be useful here, so you could have some control on what would be returned. -- nosy: +fruch __

[issue27376] Add mock_import method to mock module

2016-09-01 Thread Michael Foord
Michael Foord added the comment: Before you spend any more time on this, my current thinking is that this is a bit too specialised to belong in the standard library. I'll wait and see if a preponderance of core devs and other users disagree with me before I close this though. --

[issue27376] Add mock_import method to mock module

2016-09-01 Thread Michael Foord
Michael Foord added the comment: It's not a use case I've specifically had but I can see its use. I'm uncertain of whether that means it belongs in the module or not. Let me see if I can get some more eyes on this bug. -- ___ Python tracker

[issue27376] Add mock_import method to mock module

2016-09-01 Thread Eyal Posener
Eyal Posener added the comment: Thanks for the review, Michael. About the use case: I use it for a process with loads code and inspect it's classes and methods. When I run this process, not always I have all the dependencies of the inspected code, so I found myself mocking all those packages

[issue27376] Add mock_import method to mock module

2016-09-01 Thread Michael Foord
Michael Foord added the comment: Is this for mocking out runtime dependencies that aren't available at test time? It seems like a good way of masking bugs! I'd be happier with a (or at least an option) to specify the imports that should be mocked. The use case should be mentioned in the docs.

[issue27376] Add mock_import method to mock module

2016-09-01 Thread Michael Foord
Changes by Michael Foord : -- assignee: -> michael.foord ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https

[issue27376] Add mock_import method to mock module

2016-06-23 Thread SilentGhost
Changes by SilentGhost : -- nosy: +michael.foord stage: -> patch review ___ Python tracker ___ ___ Python-bugs-list mailing list Unsu

[issue27376] Add mock_import method to mock module

2016-06-23 Thread Eyal Posener
New submission from Eyal Posener: Add mock_import method. A helper function to mask ``ImportError``s on a scoped code, using the ``with`` statement, or in method a method used as a decorator. Failed imports will be ignored, unless specified by the *do_not_mock* argument. The *do_not_mock* argu