urllib2 test fails (2.7, linux)

guandalino guandalino at gmail.com
Thu Jul 22 19:22:48 EDT 2010


On 22 Lug, 01:13, Terry Reedy <tjre... at udel.edu> wrote:
[cut]
> > Any hint?
>
> Remove the offending fake url.

This makes tests to pass, but I have concrete reasons to think that
urllib2 is really broken on my system. Btw, a(nother) weird thing is
that I wrote a standalone test file based on test_urllib2.py and the
test that there failed now passes.

import unittest, urllib2

class Test(unittest.TestCase):
    def runTest(self):
        h = urllib2.FileHandler()
        urls = (
            "file://localhost:80/home/redt/sandbox/2.7/lib/python2.7/
test/%40test_29416_tmp",
            "file:///file_does_not_exist.txt",
            "file://127.0.0.1:80/home/home/redt/sandbox/2.7/lib/
python2.7/test/@test_29416_tmp",
            "file://somerandomhost.ontheinternet.com/home/home/redt/
sandbox/2.7/lib/python2.7/test/@test_29416_tmp",)

        for url in urls:
            self.assertRaises(urllib2.URLError, h.file_open,
urllib2.Request(url))
            print "PASSED"

PASSED
PASSED
PASSED
PASSED <-- this doesn't pass in test_urllib2 because gaierror is
raised instead of URLError.

I'm going to file an issue on python's bug tracker. Just the last
thing to be sure it's not my fault... My system already had Python
installed system wide (2.5.2) and I did the new installation in my
home directory. To "activate" the new interpreter I added /home/redt/
sandbox/2.7/bin as first element in PATH. PYTHONPATH is empty. python -
V gives 2.7.

Is it OK or new and old pythons step on each other's foot?

Thanks again,
best regards.



More information about the Python-list mailing list