From 6f442c25f1469e5b197a2e75b9d0a3854a5cfa77 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Mon, 10 Feb 2025 12:12:37 +0100 Subject: [PATCH] more tryes to fix pytest --- tests/test_components.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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):