##// END OF EJS Templates
Leak less files during test....
Matthias Bussonnier -
Show More
@@ -270,16 +270,21 b' class TempFileMixin(object):'
270 def mktmp(self, src, ext='.py'):
270 def mktmp(self, src, ext='.py'):
271 """Make a valid python temp file."""
271 """Make a valid python temp file."""
272 fname, f = temp_pyfile(src, ext)
272 fname, f = temp_pyfile(src, ext)
273 self.tmpfile = f
273 if not hasattr(self, 'tmps'):
274 self.tmps=[]
275 self.tmps.append((f, fname))
274 self.fname = fname
276 self.fname = fname
275
277
276 def tearDown(self):
278 def tearDown(self):
277 if hasattr(self, 'tmpfile'):
278 # If the tmpfile wasn't made because of skipped tests, like in
279 # If the tmpfile wasn't made because of skipped tests, like in
279 # win32, there's nothing to cleanup.
280 # win32, there's nothing to cleanup.
280 self.tmpfile.close()
281 if hasattr(self, 'tmps'):
282 for f,fname in self.tmps:
283 # If the tmpfile wasn't made because of skipped tests, like in
284 # win32, there's nothing to cleanup.
285 f.close()
281 try:
286 try:
282 os.unlink(self.fname)
287 os.unlink(fname)
283 except:
288 except:
284 # On Windows, even though we close the file, we still can't
289 # On Windows, even though we close the file, we still can't
285 # delete it. I have no clue why
290 # delete it. I have no clue why
General Comments 0
You need to be logged in to leave comments. Login now