summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2012-10-27 10:48:40 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2012-10-27 10:48:40 (GMT)
commitf8d370e30dde8ed17834f6eac8d026c6395e7101 (patch)
treed1faa5b28dfa24ac0cc2050679d68847b1c4808b /Lib
parente9992292be1693c254a34577e4366707380ccebb (diff)
downloadcpython-f8d370e30dde8ed17834f6eac8d026c6395e7101.zip
cpython-f8d370e30dde8ed17834f6eac8d026c6395e7101.tar.gz
cpython-f8d370e30dde8ed17834f6eac8d026c6395e7101.tar.bz2
Add some tests in 2.7 for Issue #16250
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_urllib.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 91aeb2f..3a273f8 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -222,6 +222,27 @@ Content-Type: text/html; charset=iso-8859-1
finally:
self.unfakehttp()
+ def test_missing_localfile(self):
+ self.assertRaises(IOError, urllib.urlopen,
+ 'file://localhost/a/missing/file.py')
+ fd, tmp_file = tempfile.mkstemp()
+ tmp_fileurl = 'file://localhost/' + tmp_file.replace(os.path.sep, '/')
+ try:
+ self.assertTrue(os.path.exists(tmp_file))
+ fp = urllib.urlopen(tmp_fileurl)
+ finally:
+ os.close(fd)
+ fp.close()
+ os.unlink(tmp_file)
+
+ self.assertFalse(os.path.exists(tmp_file))
+ self.assertRaises(IOError, urllib.urlopen, tmp_fileurl)
+
+ def test_ftp_nonexisting(self):
+ self.assertRaises(IOError, urllib.urlopen,
+ 'ftp://localhost/not/existing/file.py')
+
+
def test_userpass_inurl(self):
self.fakehttp('Hello!')
try: