Issue #12333: close files before removing the directory

packaging.tests.support.TempdirManager: rmtree() fails on Windows if there are
still open files in the directory.
This commit is contained in:
Victor Stinner 2011-06-17 13:25:53 +02:00
parent 3bcc0170bd
commit 0f270b2c37
1 changed files with 2 additions and 3 deletions

View File

@ -126,13 +126,12 @@ class TempdirManager:
self._files = []
def tearDown(self):
os.chdir(self._olddir)
shutil.rmtree(self._basetempdir)
for handle, name in self._files:
handle.close()
unlink(name)
os.chdir(self._olddir)
shutil.rmtree(self._basetempdir)
super(TempdirManager, self).tearDown()
def mktempfile(self):