urllib2 test fails (2.7, linux)
Terry Reedy
tjreedy at udel.edu
Tue Jul 20 15:24:42 EDT 2010
On 7/20/2010 7:42 AM, guandalino wrote:
> Hi, running Python 2.7 test suite for urllib2 there is a test that
> doesn't pass.
> Do you have an idea about where the problem could be and how to solve
> it?
>
> Thanks,
> best regards.
>
> $ # ubuntu 8.04
> $ pwd
> ~/sandbox/2.7/lib/python2.7/test
> $ python test_urllib2.py
> ======================================================================
> ERROR: test_file (__main__.HandlerTests)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "test_urllib2.py", line 711, in test_file
> h.file_open, Request(url))
Look there to find the complete statement. For 3.1, it would be
self.assertRaises(urllib.error.URLError,
h.file_open, Request(url))
(urllib2 is now urllib.request)
You could insert a print to find what url caused a problem.
> File "/home/redt/sandbox/2.7/lib/python2.7/unittest/case.py", line
This puzzles me. In 3.1, unittest is a module, unittest.py, not a
package containing modules like 'case.py'. I though it was the same for 2.7
> 456, in assertRaises
> callableObj(*args, **kwargs)
This is in unittest.py. It says that this test case *should* fail, but
with a different error (urllib.error.URLError) than the one you got
(gaierror).
> File "/home/redt/sandbox/2.7/lib/python2.7/urllib2.py", line 1269,
> in file_open
> return self.open_local_file(req)
> File "/home/redt/sandbox/2.7/lib/python2.7/urllib2.py", line 1301,
> in open_local_file
> (not port and socket.gethostbyname(host) in self.get_names()):
> gaierror: [Errno -5] No address associated with hostname
gaierror comes from socket.gethostbyname
> Finally, I don't know if this matters but the tests have been executed
> offline (without an internet connection).
Since error is in open_local_file, I would think not.
--
Terry Jan Reedy
More information about the Python-list
mailing list