Skip to content

Commit

Permalink
try sudo
Browse files Browse the repository at this point in the history
Signed-off-by: harupy <hkawamura0130@gmail.com>
  • Loading branch information
harupy committed Nov 29, 2021
1 parent d4777cf commit 60572a6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/conftest.py
@@ -1,7 +1,7 @@
import os
import stat
import inspect
import shutil
import subprocess
from unittest import mock

import pytest
Expand Down Expand Up @@ -100,11 +100,6 @@ def new_exception(msg, *_, **__):
yield


def on_rm_error(func, path, exc_info): # pylint: disable=unused-argument
os.chmod(path, stat.S_IWRITE)
os.unlink(path)


@pytest.fixture(autouse=True, scope="module")
def clean_up_mlruns_direcotry(request):
"""
Expand All @@ -113,4 +108,9 @@ def clean_up_mlruns_direcotry(request):
yield
mlruns_dir = os.path.join(request.config.rootpath, "mlruns")
if os.path.exists(mlruns_dir):
shutil.rmtree(mlruns_dir, onerror=on_rm_error)
try:
shutil.rmtree(mlruns_dir)
except IOError:
if os.name == "nt":
raise
subprocess.run(["sudo", "rm", "-rf", mlruns_dir], check=True)

0 comments on commit 60572a6

Please sign in to comment.