Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_urllibnet.test_bad_address() fails when using OpenDNS #47833

Closed
brettcannon opened this issue Aug 17, 2008 · 7 comments
Closed

test_urllibnet.test_bad_address() fails when using OpenDNS #47833

brettcannon opened this issue Aug 17, 2008 · 7 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@brettcannon
Copy link
Member

BPO 3583
Nosy @brettcannon, @orsenthil, @pitrou, @devdanzin, @ezio-melotti, @bitdancer
Dependencies
  • bpo-10775: assertRaises as a context manager should accept a 'msg' keyword argument.
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2013-01-11.16:18:15.354>
    created_at = <Date 2008-08-17.21:21:01.098>
    labels = ['type-bug', 'tests']
    title = 'test_urllibnet.test_bad_address() fails when using OpenDNS'
    updated_at = <Date 2013-01-11.16:18:15.353>
    user = 'https://github.com/brettcannon'

    bugs.python.org fields:

    activity = <Date 2013-01-11.16:18:15.353>
    actor = 'brett.cannon'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-01-11.16:18:15.354>
    closer = 'brett.cannon'
    components = ['Tests']
    creation = <Date 2008-08-17.21:21:01.098>
    creator = 'brett.cannon'
    dependencies = ['10775']
    files = []
    hgrepos = []
    issue_num = 3583
    keywords = []
    message_count = 7.0
    messages = ['71292', '71319', '71352', '71353', '87786', '124676', '179693']
    nosy_count = 7.0
    nosy_names = ['brett.cannon', 'orsenthil', 'pitrou', 'ajaksu2', 'ezio.melotti', 'r.david.murray', 'python-dev']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = 'needs patch'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue3583'
    versions = ['Python 3.3']

    @brettcannon
    Copy link
    Member Author

    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.

    @brettcannon brettcannon added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Aug 17, 2008
    @pitrou
    Copy link
    Member

    pitrou commented Aug 18, 2008

    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.

    @brettcannon
    Copy link
    Member Author

    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?

    @pitrou
    Copy link
    Member

    pitrou commented Aug 18, 2008

    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.

    @devdanzin devdanzin mannequin added tests Tests in the Lib/test dir and removed stdlib Python modules in the Lib dir labels Feb 12, 2009
    @ezio-melotti
    Copy link
    Member

    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 bpo-6027).

    @bitdancer
    Copy link
    Member

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 11, 2013

    New changeset acce13a6e728 by Brett Cannon in branch 'default':
    Issue bpo-3583: mention that testing whether a bad address not triggering
    http://hg.python.org/cpython/rev/acce13a6e728

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants