windows doesn't like to let go of files

This commit is contained in:
sneakers-the-rat 2024-07-31 16:25:59 -07:00
parent 886cc893d8
commit 0a930eed35
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D

View file

@ -1,6 +1,7 @@
import shutil import shutil
from pathlib import Path from pathlib import Path
from typing import Any, Callable, Optional, Tuple, Type, Union from typing import Any, Callable, Optional, Tuple, Type, Union
from warnings import warn
import h5py import h5py
import numpy as np import numpy as np
@ -25,7 +26,13 @@ def tmp_output_dir(request: pytest.FixtureRequest) -> Path:
yield path yield path
if not request.config.getvalue("--with-output"): if not request.config.getvalue("--with-output"):
try:
shutil.rmtree(str(path)) shutil.rmtree(str(path))
except PermissionError as e:
# sporadic error on windows machines...
warn(
f"Temporary directory could not be removed due to a permissions error: \n{str(e)}"
)
@pytest.fixture(scope="function") @pytest.fixture(scope="function")