[TIP] Mocking native Python2/3 code

Chris Down chris at chrisdown.name
Wed Jan 1 00:56:32 PST 2014


On 2014-01-01 16:27:52 +0800, Chris Down wrote:
> Hello,
> 
> Currently, I do the following in my code to mock urlopen for Python 3:
> 
>     @patch("urllib.request.urlopen")
>     def test_something(urlopen_mock):
>         ...

Whoops, that's my bad. I totally misunderstood how the mocking was
supposed to work -- once I use @patch("[module].urlopen"), it works just
fine.

Apologies for the noise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140101/2ab801e0/attachment.pgp>


More information about the testing-in-python mailing list