Skip to content

Commit

Permalink
more tryes to fix pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
mirpedrol committed Feb 10, 2025
1 parent 76e56c5 commit 6f442c2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import shutil
import stat
import tempfile
import unittest
from pathlib import Path
Expand All @@ -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"""

Expand All @@ -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):
Expand Down

0 comments on commit 6f442c2

Please sign in to comment.