classification
Title: test_urllibnet.test_bad_address() fails when using OpenDNS
Type: behavior Stage: needs patch
Components: Tests Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: 10775 Superseder:
Assigned To: Nosy List: ajaksu2, brett.cannon, ezio.melotti, orsenthil, pitrou, python-dev, r.david.murray
Priority: low Keywords:

Created on 2008-08-17 21:21 by brett.cannon, last changed 2013-01-11 16:18 by brett.cannon. This issue is now closed.

Messages (7)
msg71292 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-08-17 21:21
OpenDNS has a "feature" where if you enter an address that doesn't
exist, you get a 404 and a Google-looking search page. Problem is that
urllib.urlopen() does not raise any exception on a 404.

Probably should just change the test such that if no exception is
raised, check if a 404 was returned and still consider the test passed.
msg71319 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-18 10:52
Are many people using OpenDNS? Is there a way to detect that OpenDNS is
being used and trigger a separate path in the test?
I say that because returning a 404 when the domain lookup has failed is
wrong. Perhaps the test should check for a 404 and still raise an
exception, but with an appropriate message indicating that it may be due
to a "featureful" DNS service.
msg71352 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-08-18 17:19
On Mon, Aug 18, 2008 at 3:52 AM, Antoine Pitrou <report@bugs.python.org> wrote:
>
> Antoine Pitrou <pitrou@free.fr> added the comment:
>
> Are many people using OpenDNS? Is there a way to detect that OpenDNS is
> being used and trigger a separate path in the test?
> I say that because returning a 404 when the domain lookup has failed is
> wrong. Perhaps the test should check for a 404 and still raise an
> exception, but with an appropriate message indicating that it may be due
> to a "featureful" DNS service.
>

That's also a possibility.

Out of curiosity, what HTTP response should be received?
msg71353 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-18 17:50
Le lundi 18 août 2008 à 17:19 +0000, Brett Cannon a écrit :
> That's also a possibility.
> 
> Out of curiosity, what HTTP response should be received?

There shouldn't be an HTTP response at all. If DNS lookup fails,
connecting to the server simply fails.
msg87786 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-05-15 01:39
I got a similar problem but here the ISP returned an error/search page
and a "302 Found". test_urllibnet.test_bad_address() failed with
"AssertionError: IOError not raised by urlopen"

>>> import http.client
>>> conn = http.client.HTTPConnection("www.somerandominvalidpage.edu")
>>> conn.request("GET", "/")
>>> r1 = conn.getresponse()
>>> r1.status, r1.reason
(302, 'Found')

test_xmlrpc_net failed for the same reason (see #6027).
msg124676 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-26 19:30
I think the best we can do here is add a message explaining that the error may be due to a broken DNS server (one with a wildcard dns record for all non-existent top level domains).  However, assertRaises, even in context manager form, doesn't take a msg argument (yet).  I've opened an issue with a feature request to fix that and made it a dependency of this issue.

Note that the test uses a domain name ending in ".d", and for a while before that used '.invalid', so the test should not fail if the ISP is only capturing valid top level domains with wildcards, something that seems to be far more common than catching invalid domains.
msg179693 - (view) Author: Roundup Robot (python-dev) Date: 2013-01-11 16:18
New changeset acce13a6e728 by Brett Cannon in branch 'default':
Issue #3583: mention that testing whether a bad address not triggering
http://hg.python.org/cpython/rev/acce13a6e728
History
Date User Action Args
2013-01-11 16:18:15brett.cannonsetstatus: open -> closed
resolution: fixed
2013-01-11 16:18:00python-devsetnosy: + python-dev
messages: + msg179693
2010-12-26 19:30:18r.david.murraysetpriority: normal -> low

dependencies: + assertRaises as a context manager should accept a 'msg' keyword argument.
versions: + Python 3.3, - Python 2.6, Python 3.1
nosy: + r.david.murray

messages: + msg124676
stage: test needed -> needs patch
2009-05-16 21:39:35ajaksu2setnosy: + ajaksu2

versions: + Python 3.1, - Python 3.0
2009-05-15 01:39:18ezio.melottisetnosy: + ezio.melotti
messages: + msg87786
2009-02-12 17:53:49ajaksu2setnosy: + orsenthil
stage: test needed
components: + Tests, - Library (Lib)
versions: + Python 3.0
2008-08-18 17:50:17pitrousetmessages: + msg71353
2008-08-18 17:19:17brett.cannonsetmessages: + msg71352
2008-08-18 10:52:23pitrousetnosy: + pitrou
messages: + msg71319
2008-08-17 21:21:01brett.cannoncreate