This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sih4sing5hong5
Recipients sih4sing5hong5
Date 2015-08-13.06:56:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1439448977.69.0.239329434858.issue24855@psf.upfronthosting.co.za>
In-reply-to
Content
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 openPatch(urlopenMock):
    print(urlopenMock)
    print(urlopen)
    print(request.urlopen)
    print(urllib.request.urlopen)

openPatch()
```
and got

```
<MagicMock name='urlopen' id='140645541554384'>
<function urlopen at 0x7fea9764c268>
<MagicMock name='urlopen' id='140645541554384'>
<MagicMock name='urlopen' id='140645541554384'>
```
request.urlopen and urllib.request.urlopen worked. Why urlopen had been not mocked?
History
Date User Action Args
2015-08-13 06:56:17sih4sing5hong5setrecipients: + sih4sing5hong5
2015-08-13 06:56:17sih4sing5hong5setmessageid: <1439448977.69.0.239329434858.issue24855@psf.upfronthosting.co.za>
2015-08-13 06:56:17sih4sing5hong5linkissue24855 messages
2015-08-13 06:56:17sih4sing5hong5create