From 0a930eed35d4425967907a8c8816413255b11b06 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Wed, 31 Jul 2024 16:25:59 -0700 Subject: [PATCH] windows doesn't like to let go of files --- tests/fixtures.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index e780058..7c14b35 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -1,6 +1,7 @@ import shutil from pathlib import Path from typing import Any, Callable, Optional, Tuple, Type, Union +from warnings import warn import h5py import numpy as np @@ -25,7 +26,13 @@ def tmp_output_dir(request: pytest.FixtureRequest) -> Path: yield path if not request.config.getvalue("--with-output"): - shutil.rmtree(str(path)) + try: + 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")