From b25f28c5a7dcb2caa58747982aced1478aac02f2 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Fri, 1 Nov 2024 02:20:17 -0700 Subject: [PATCH] try finally rmtree Co-authored-by: Moritz E. Beber --- tests/conftest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 68f9c5b..888f6dd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -62,9 +62,10 @@ def cleanup_hatch_envs( hatch_dir = tmp_path_factory.mktemp("hatch") monkeypatch_session.setenv("HATCH_DATA_DIR", str(hatch_dir)) - yield - - shutil.rmtree(hatch_dir, ignore_errors=True) + try: + yield + finally: + shutil.rmtree(hatch_dir, ignore_errors=True) # --------------------------------------------- # Fixtures - exports