[Python-checkins] cpython (2.7): Add some tests in 2.7 for Issue #16250

senthil.kumaran python-checkins at python.org
Sat Oct 27 12:48:58 CEST 2012


http://hg.python.org/cpython/rev/3fb84c1da8c5
changeset:   79960:3fb84c1da8c5
branch:      2.7
parent:      79956:937fa81500e2
user:        Senthil Kumaran <senthil at uthcode.com>
date:        Sat Oct 27 03:48:40 2012 -0700
summary:
  Add some tests in 2.7 for Issue #16250

files:
  Lib/test/test_urllib.py |  21 +++++++++++++++++++++
  1 files changed, 21 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -222,6 +222,27 @@
         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:

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list