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 <[email protected]>
  • Loading branch information
vinnamkim committed Sep 21, 2023
1 parent 1777f45 commit 8728679
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 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,20 @@ 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 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)

if not os.path.exists(self.path):
return
sleep(0.5)


class TestDir(FileRemover):
Expand Down

0 comments on commit 8728679

Please sign in to comment.