[issue39551] mock patch should match behavior of import from when module isn't present in sys.modules

Chris Withers report at bugs.python.org
Sun Feb 9 15:12:34 EST 2020


Chris Withers <chris at withers.org> added the comment:

Hmm, the more we get into this, the less comfortable I am of the patch in the PR.

Instead of copying and pasting more code that's likely to get out of sync, could you change the PR to just replace _importer with the correct parts of importlib to support your usecase?

Keep the unit test though, useful to show in mock why the change is needed, and make sure we do something sensible in the backport!

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39551>
_______________________________________


More information about the Python-bugs-list mailing list