Skip to content

Commit

Permalink
Try rmtree() several times
Browse files Browse the repository at this point in the history
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
  • Loading branch information
vinnamkim committed Sep 21, 2023
1 parent bdb96e6 commit d7e17c4
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions tests/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
import tempfile
import unittest
import unittest.mock
import warnings
from enum import Enum, auto
from glob import glob
from tempfile import TemporaryDirectory
from time import sleep
from typing import Any, Collection, List, Optional, Union

import pytest
Expand Down Expand Up @@ -45,15 +44,21 @@ def __enter__(self):
return self.path

def __exit__(self, exc_type=None, exc_value=None, traceback=None):
if self.is_dir:
try:
rmtree(self.path)
except unittest.SkipTest:
# Suppress skip test errors from git.util.rmtree
if not exc_type:
raise
else:
rmfile(self.path)
for _ in range(10):
if not os.path.exists(self.path):
return

if self.is_dir:
try:
rmtree(self.path)
except unittest.SkipTest:
# Suppress skip test errors from git.util.rmtree
if not exc_type:
raise
else:
rmfile(self.path)

sleep(0.5)


class TestDir(FileRemover):
Expand Down

0 comments on commit d7e17c4

Please sign in to comment.