Fix cleanup of symlink fixtures
These aren't all getting cleaned up, which winds up breaking the second runs. Instead of doing addCleanup with a method that does the loop again, which can fail in the middle and not clean up subsequent files, add an individual cleanup when we add the symlink. This results in all of the symlinks consistently being cleaned. Change-Id: Id5a5b09c830ad2ad3bb0b77fb9dbdc494c629824
This commit is contained in:
@ -43,17 +43,10 @@ class SymlinkFixture(fixtures.Fixture):
|
||||
]
|
||||
|
||||
def _setUp(self):
|
||||
self._cleanup()
|
||||
for (src, target) in self.links:
|
||||
path = os.path.join(FIXTURE_DIR, 'links', src)
|
||||
os.symlink(target, path)
|
||||
self.addCleanup(self._cleanup)
|
||||
|
||||
def _cleanup(self):
|
||||
for (src, target) in self.links:
|
||||
path = os.path.join(FIXTURE_DIR, 'links', src)
|
||||
if os.path.exists(path):
|
||||
os.unlink(path)
|
||||
self.addCleanup(os.unlink, path)
|
||||
|
||||
|
||||
class TestFileList(testtools.TestCase):
|
||||
|
@ -44,17 +44,10 @@ class SymlinkFixture(fixtures.Fixture):
|
||||
]
|
||||
|
||||
def _setUp(self):
|
||||
self._cleanup()
|
||||
for (src, target) in self.links:
|
||||
path = os.path.join(FIXTURE_DIR, 'links', src)
|
||||
os.symlink(target, path)
|
||||
self.addCleanup(self._cleanup)
|
||||
|
||||
def _cleanup(self):
|
||||
for (src, target) in self.links:
|
||||
path = os.path.join(FIXTURE_DIR, 'links', src)
|
||||
if os.path.exists(path):
|
||||
os.unlink(path)
|
||||
self.addCleanup(os.unlink, path)
|
||||
|
||||
|
||||
class TestFileList(testtools.TestCase):
|
||||
|
@ -44,17 +44,10 @@ class SymlinkFixture(fixtures.Fixture):
|
||||
]
|
||||
|
||||
def _setUp(self):
|
||||
self._cleanup()
|
||||
for (src, target) in self.links:
|
||||
path = os.path.join(FIXTURE_DIR, 'links', src)
|
||||
os.symlink(target, path)
|
||||
self.addCleanup(self._cleanup)
|
||||
|
||||
def _cleanup(self):
|
||||
for (src, target) in self.links:
|
||||
path = os.path.join(FIXTURE_DIR, 'links', src)
|
||||
if os.path.exists(path):
|
||||
os.unlink(path)
|
||||
self.addCleanup(os.unlink, path)
|
||||
|
||||
|
||||
class TestFileList(testtools.TestCase):
|
||||
|
@ -44,17 +44,10 @@ class SymlinkFixture(fixtures.Fixture):
|
||||
]
|
||||
|
||||
def _setUp(self):
|
||||
self._cleanup()
|
||||
for (src, target) in self.links:
|
||||
path = os.path.join(FIXTURE_DIR, 'links', src)
|
||||
os.symlink(target, path)
|
||||
self.addCleanup(self._cleanup)
|
||||
|
||||
def _cleanup(self):
|
||||
for (src, target) in self.links:
|
||||
path = os.path.join(FIXTURE_DIR, 'links', src)
|
||||
if os.path.exists(path):
|
||||
os.unlink(path)
|
||||
self.addCleanup(os.unlink, path)
|
||||
|
||||
|
||||
class TestFileList(testtools.TestCase):
|
||||
|
Reference in New Issue
Block a user