blob: 8238bcae37659b6253f9713b7a69a2b599423e9b [file] [log] [blame]
Barry Warsaw04f357c2002-07-23 19:04:11 +00001from test.test_support import verify
Jeremy Hyltone3e61042001-05-09 15:50:25 +00002import urllib2
Tim Peters861adac2001-07-16 20:49:49 +00003import os
Jeremy Hyltone3e61042001-05-09 15:50:25 +00004
5# A couple trivial tests
6
7try:
8 urllib2.urlopen('bogus url')
9except ValueError:
10 pass
11else:
12 verify(0)
13
Tim Peters861adac2001-07-16 20:49:49 +000014# XXX Name hacking to get this to work on Windows.
15fname = os.path.abspath(urllib2.__file__).replace('\\', '/')
16if fname[1:2] == ":":
17 fname = fname[2:]
Jack Jansen535c5242001-08-27 22:31:58 +000018# And more hacking to get it to work on MacOS. This assumes
19# urllib.pathname2url works, unfortunately...
20if os.name == 'mac':
Tim Peters83e7ccc2001-09-04 06:37:28 +000021 fname = '/' + fname.replace(':', '/')
Guido van Rossume2ae77b2001-10-24 20:42:55 +000022elif os.name == 'riscos':
23 import string
24 fname = os.expand(fname)
25 fname = fname.translate(string.maketrans("/.", "./"))
26
Tim Peters861adac2001-07-16 20:49:49 +000027file_url = "file://%s" % fname
Jeremy Hyltone3e61042001-05-09 15:50:25 +000028f = urllib2.urlopen(file_url)
Tim Peters861adac2001-07-16 20:49:49 +000029
Jeremy Hyltone3e61042001-05-09 15:50:25 +000030buf = f.read()
31f.close()