Commit bf644c55 authored by Senthil Kumaran's avatar Senthil Kumaran

Fix the windows buildbot permission error - close the fd of tempfile beffore unlinking

parent 3194d7cf
...@@ -278,11 +278,12 @@ Content-Type: text/html; charset=iso-8859-1 ...@@ -278,11 +278,12 @@ Content-Type: text/html; charset=iso-8859-1
def test_file_notexists(self): def test_file_notexists(self):
fd, tmp_file = tempfile.mkstemp() fd, tmp_file = tempfile.mkstemp()
tmp_fileurl = 'file://localhost/' + tmp_file.replace(os.path.sep, '/') tmp_fileurl = 'file://localhost/' + tmp_file.replace(os.path.sep, '/')
try:
self.assertTrue(os.path.exists(tmp_file)) self.assertTrue(os.path.exists(tmp_file))
with urlopen(tmp_fileurl) as fobj: with urlopen(tmp_fileurl) as fobj:
self.assertTrue(fobj) self.assertTrue(fobj)
finally:
os.close(fd)
os.unlink(tmp_file) os.unlink(tmp_file)
self.assertFalse(os.path.exists(tmp_file)) self.assertFalse(os.path.exists(tmp_file))
with self.assertRaises(urllib.error.URLError): with self.assertRaises(urllib.error.URLError):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment