diff --git a/tests/test_components.py b/tests/test_components.py index 2184319a2..f5c174566 100644 --- a/tests/test_components.py +++ b/tests/test_components.py @@ -2,6 +2,7 @@ import os import shutil +import stat import tempfile import unittest from pathlib import Path @@ -12,6 +13,12 @@ from .utils import GITLAB_NFTEST_BRANCH, GITLAB_URL +def remove_readonly(func, path, _): + "Clear the readonly bit and reattempt the removal" + os.chmod(path, stat.S_IWRITE) + func(path) + + class TestComponents(unittest.TestCase): """Class for components tests""" @@ -31,7 +38,7 @@ def tearDown(self): # Clean up temporary files if self.tmp_dir.is_dir(): - shutil.rmtree(self.tmp_dir, ignore_errors=True) + shutil.rmtree(self.tmp_dir, onexc=remove_readonly) @pytest.fixture(autouse=True) def _use_caplog(self, caplog):