summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib.py
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2012-10-23 18:07:02 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2012-10-23 18:07:02 (GMT)
commitbf644c5571a8e2acb380c7a1288af217f0be7cd6 (patch)
tree3b77def78c32723bbf1e63ae9960eef438569f6b /Lib/test/test_urllib.py
parent3194d7cfcef24bf69436cb430b751c74838392e1 (diff)
downloadcpython-bf644c5571a8e2acb380c7a1288af217f0be7cd6.zip
cpython-bf644c5571a8e2acb380c7a1288af217f0be7cd6.tar.gz
cpython-bf644c5571a8e2acb380c7a1288af217f0be7cd6.tar.bz2
Fix the windows buildbot permission error - close the fd of tempfile beffore unlinking
Diffstat (limited to 'Lib/test/test_urllib.py')
-rw-r--r--Lib/test/test_urllib.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 2eac4e3..d8c3512 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -278,12 +278,13 @@ Content-Type: text/html; charset=iso-8859-1
def test_file_notexists(self):
fd, tmp_file = tempfile.mkstemp()
tmp_fileurl = 'file://localhost/' + tmp_file.replace(os.path.sep, '/')
-
- self.assertTrue(os.path.exists(tmp_file))
- with urlopen(tmp_fileurl) as fobj:
- self.assertTrue(fobj)
-
- os.unlink(tmp_file)
+ try:
+ self.assertTrue(os.path.exists(tmp_file))
+ with urlopen(tmp_fileurl) as fobj:
+ self.assertTrue(fobj)
+ finally:
+ os.close(fd)
+ os.unlink(tmp_file)
self.assertFalse(os.path.exists(tmp_file))
with self.assertRaises(urllib.error.URLError):
urlopen(tmp_fileurl)