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

Chris Withers report at bugs.python.org
Thu Feb 6 13:55:01 EST 2020


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

Apologies, but I'm still not sure what "the modules are published" means?
"publish "x" as a child onto the package" also doesn't mean much to me, I'm afraid. Are you aware of any importlib docs or some such which might be able to explain this to me?

When "It can still have normal Python modules as a child which aren't immutable", what happens when you try to patch the immutable module? What happens if you try to patch the mutable module below it?

When "the assignment is ignored with a warning.", what is doing that ignoring?

Unless I'm missing something, this feels like such an edge case I'm not sure mock.patch should be trying to support it. Should this be something that is handled by your immutable import thing?

----------

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


More information about the Python-bugs-list mailing list