R. David Murray added the comment:

It has nothing to do with __all__, and everything to do with the way namespaces 
work in Python.  'from urllib.request import urllib' creates a name 'urllib' in 
the global namespace of your module pointing to the urlopen function (*before* 
you do your patch), and patch has no effect on the global namespace of your 
module, only on the global namespace of urllib.request.  By contrast, urllib in 
your module's global namespace points to the urllib module, so urllib.request 
points to the urllib.request's global namespace, which patch has altered to 
point to your mock by the time you print its value.

----------
nosy: +r.david.murray

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24855>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to