2001-05-09 15:50:25 +00:00
|
|
|
from test_support import verify
|
|
|
|
import urllib2
|
2001-07-16 20:49:49 +00:00
|
|
|
import os
|
2001-05-09 15:50:25 +00:00
|
|
|
|
|
|
|
# A couple trivial tests
|
|
|
|
|
|
|
|
try:
|
|
|
|
urllib2.urlopen('bogus url')
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
verify(0)
|
|
|
|
|
2001-07-16 20:49:49 +00:00
|
|
|
# XXX Name hacking to get this to work on Windows.
|
|
|
|
fname = os.path.abspath(urllib2.__file__).replace('\\', '/')
|
|
|
|
if fname[1:2] == ":":
|
|
|
|
fname = fname[2:]
|
2001-08-27 22:31:58 +00:00
|
|
|
# And more hacking to get it to work on MacOS. This assumes
|
|
|
|
# urllib.pathname2url works, unfortunately...
|
|
|
|
if os.name == 'mac':
|
|
|
|
fname = '/' + fname.replace(':', '/')
|
2001-07-16 20:49:49 +00:00
|
|
|
file_url = "file://%s" % fname
|
2001-05-09 15:50:25 +00:00
|
|
|
f = urllib2.urlopen(file_url)
|
2001-07-16 20:49:49 +00:00
|
|
|
|
2001-05-09 15:50:25 +00:00
|
|
|
buf = f.read()
|
|
|
|
f.close()
|