Add error-handling function to shutil.rmtree

This commit is contained in:
twangboy 2017-07-11 13:08:00 -06:00
parent 81695a9f3c
commit 45be32666a

View file

@ -16,6 +16,7 @@ import tempfile
import shutil
import subprocess
import yaml
import stat
# Import Salt Testing libs
from tests.integration import AdaptedConfigurationTestCaseMixin
@ -72,9 +73,13 @@ class GitPillarTestCase(TestCase, AdaptedConfigurationTestCaseMixin, LoaderModul
git_pillar._update('master', 'file://{0}'.format(self.repo_path))
def tearDown(self):
shutil.rmtree(self.tmpdir)
shutil.rmtree(self.tmpdir, onerror=self._rmtree_error)
super(GitPillarTestCase, self).tearDown()
def _rmtree_error(self, func, path, excinfo):
os.chmod(path, stat.S_IWRITE)
func(path)
def _create_repo(self):
'create source Git repo in temp directory'
repo = os.path.join(self.tmpdir, 'repo_pillar')