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 1777f45 commit 294193c
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 294193c

Please sign in to comment.