diff --git a/tests/rr/test_fnm.py b/tests/rr/test_fnm.py index dd399591e..f7345b516 100644 --- a/tests/rr/test_fnm.py +++ b/tests/rr/test_fnm.py @@ -330,8 +330,11 @@ def test_fnm_save_as_with_recurse_correctly_copies_subfiles(): target_path = test_output_dir / name if target_path.exists() and target_path.is_dir(): - shutil.rmtree(target_path) - target_path.mkdir() + try: + shutil.rmtree(target_path) + except PermissionError: + pass + target_path.mkdir(exist_ok=True) with file_load_context() as context: context.push_new_parent(source_path_parent, ResolveRelativeMode.ToParent) @@ -359,8 +362,12 @@ def test_fnm_save_without_recurse_only_copies_fnm_file(): target_path = test_output_dir / name if target_path.exists() and target_path.is_dir(): - shutil.rmtree(target_path) - target_path.mkdir() + try: + shutil.rmtree(target_path) + except PermissionError: + pass + + target_path.mkdir(exist_ok=True) with file_load_context() as context: context.push_new_parent(source_path_parent, ResolveRelativeMode.ToParent) @@ -387,8 +394,11 @@ def test_dimr_model_save_with_recurse_correctly_copies_rr_sub_files(): target_path = test_output_dir / name if target_path.exists() and target_path.is_dir(): - shutil.rmtree(target_path) - target_path.mkdir() + try: + shutil.rmtree(target_path) + except PermissionError: + pass + target_path.mkdir(exist_ok=True) with file_load_context() as context: context.push_new_parent(source_path_parent, ResolveRelativeMode.ToParent) diff --git a/tests/test_basemodel.py b/tests/test_basemodel.py index b98cbd9f7..f29a41d27 100644 --- a/tests/test_basemodel.py +++ b/tests/test_basemodel.py @@ -159,10 +159,16 @@ def test_save_and_load_maintains_correct_paths( ) if _external_path.exists(): - shutil.rmtree(_external_path) + try: + shutil.rmtree(_external_path) + except PermissionError: + pass if output_dir.exists(): - shutil.rmtree(output_dir) + try: + shutil.rmtree(output_dir) + except PermissionError: + pass model_path = output_dir / "fm.mdu" @@ -403,7 +409,7 @@ def create_bc_file(self, tmp_path: Path, name: str): Name = global Function = timeseries Time-interpolation = linear -Quantity = time +Quantity = time Unit = minutes since 2006-12-25 0:00:00 Quantity = rainfall_rate Unit = mm day-1 @@ -431,7 +437,7 @@ def change_bc_file(self, tmp_path: Path, name: str): Name = little_change_to_the_file Function = timeseries Time-interpolation = linear -Quantity = time +Quantity = time Unit = minutes since 2006-12-25 0:00:00 Quantity = rainfall_rate Unit = mm day-1 diff --git a/tests/test_model.py b/tests/test_model.py index f40798013..e89fc311a 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -192,7 +192,10 @@ def test_mdu_model(): output_fn = output_dir / FMModel._generate_name() if output_dir.exists(): - shutil.rmtree(output_dir) + try: + shutil.rmtree(output_dir) + except PermissionError: + pass model.save(filepath=output_fn, recurse=True)