From: Senthil Kumaran Date: Sat, 1 Jun 2013 14:59:10 +0000 (-0700) Subject: Fix #16450 test_missing_localfile testcase fails on misconfigured hostname. X-Git-Tag: v2.7.6rc1~367 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a085f000b4ecf409ef29e38431ebbd198e7bbb31;p=thirdparty%2FPython%2Fcpython.git Fix #16450 test_missing_localfile testcase fails on misconfigured hostname. Refactor test to accomodate that and exercise the needed functionality. --- diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 3a273f873b1b..e60adb233572 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -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)