]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix #16450 test_missing_localfile testcase fails on misconfigured hostname.
authorSenthil Kumaran <senthil@uthcode.com>
Sat, 1 Jun 2013 14:59:10 +0000 (07:59 -0700)
committerSenthil Kumaran <senthil@uthcode.com>
Sat, 1 Jun 2013 14:59:10 +0000 (07:59 -0700)
Refactor test to accomodate that and exercise the needed functionality.

Lib/test/test_urllib.py

index 3a273f873b1bd004712c64105d7a05c12ce2d5c1..e60adb2335725255f26796124cce906a466d7622 100644 (file)
@@ -227,13 +227,13 @@ Content-Type: text/html; charset=iso-8859-1
                 'file://localhost/a/missing/file.py')
         fd, tmp_file = tempfile.mkstemp()
         tmp_fileurl = 'file://localhost/' + tmp_file.replace(os.path.sep, '/')
+        self.assertTrue(os.path.exists(tmp_file))
         try:
-            self.assertTrue(os.path.exists(tmp_file))
             fp = urllib.urlopen(tmp_fileurl)
+            fp.close()
         finally:
             os.close(fd)
-            fp.close()
-        os.unlink(tmp_file)
+            os.unlink(tmp_file)
 
         self.assertFalse(os.path.exists(tmp_file))
         self.assertRaises(IOError, urllib.urlopen, tmp_fileurl)