[issue24855] fail to mock the urlopen function

2015-08-16 Thread sih4sing5hong5
sih4sing5hong5 added the comment: I moved the import urlopen inside the patch. The mock worked. Thank you for explanations. I understand now. -- ___ Python tracker ___ _

[issue24855] fail to mock the urlopen function

2015-08-13 Thread R. David Murray
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),

[issue24855] fail to mock the urlopen function

2015-08-13 Thread sih4sing5hong5
sih4sing5hong5 added the comment: It is normal because of __all__ syntax. By: https://github.com/testing-cabal/mock/issues/313#issuecomment-130564364 -- status: open -> closed ___ Python tracker __

[issue24855] fail to mock the urlopen function

2015-08-12 Thread sih4sing5hong5
New submission from sih4sing5hong5: I also posted in stackoverflow: http://stackoverflow.com/questions/30978207/python-urlopen-mock-fail ``` from unittest.mock import patch import urllib from urllib import request from urllib.request import urlopen @patch('urllib.request.urlopen') def openPatc