shazow/urllib3 — comment on commit 99cd0a3c68de889af1cbcf82580d24057ab8a29d
File: dummyserver/testcase.py line 21
By brandon-rhodes:

It is a big fragile — as well as slightly less efficient — to rely on the hostname `localhost` to be available and properly configured (yes, this is actually something that some newbie Linux admins and Windows users will break while trying to fix some other crazy problem with the help of some blog entry!). Unless you are specifically testing whether `urllib3` accepts hostnames — which, I must admit, you are quite correct for wanting to test in at least one or two tests — you might want to use `127.0.0.1` here which avoids a call out to DNS and which, for the test to work, only requires the loopback to be up and running.

And I must admit that even relying on loopback is dicey — just a few months ago I had one or two quite confusing days of random errors until I discovered that I had somehow convinced Gnome that I did not want my loopback brought up at boot time. :)