[New-bugs-announce] [issue9446] urllib2 tests fail when offline

Guandalino report at bugs.python.org
Sun Aug 1 12:30:13 CEST 2010

New submission from Guandalino <guandalino at gmail.com>:

urllib2 tests fail when internet connection is not available.

$ cd ~/sandbox/2.7/lib/python2.7/test
$ python test_urllib2.py

other output, [cut]

ERROR: test_file (__main__.HandlerTests)
Traceback (most recent call last):
  File "test_urllib2.py", line 711, in test_file
    h.file_open, Request(url))
  File "/home/redt/sandbox/2.7/lib/python2.7/unittest/case.py", line 456, in assertRaises
    callableObj(*args, **kwargs)
  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

Ran 34 tests in 0.414s

FAILED (errors=1)

The issue verifies using ubuntu 8.04 LTS having this /etc/hosts: localhost localhost.localdomain speedy

::1 localhost speedy ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts 

Note that when connected to internet all the tests pass.

Further details can be found in a thread I started 
on comp.lang.python. http://bit.ly/9x9Umu.

I can't guarantee a quick answer but let me know if other info are required, I'll be glad to provide them asap. Thank you.

components: Installation, Library (Lib), Tests
files: offline.log
messages: 112307
nosy: benjamin.peterson, ezio.melotti, guandalino, orsenthil, tjreedy
priority: normal
severity: normal
status: open
title: urllib2 tests fail when offline
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file18306/offline.log

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list