From 1fcd373f33d276ca711da34bb5879b2a756aad86 Mon Sep 17 00:00:00 2001 From: Ioannis Tziakos Date: Sat, 17 Aug 2024 12:26:36 +0100 Subject: [PATCH] More robust teardown for tests on windows --- zipfile2/tests/test__zipfile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zipfile2/tests/test__zipfile.py b/zipfile2/tests/test__zipfile.py index 0567361..9730f27 100644 --- a/zipfile2/tests/test__zipfile.py +++ b/zipfile2/tests/test__zipfile.py @@ -577,7 +577,12 @@ def setUp(self): os.remove(path) def tearDown(self): - shutil.rmtree(self.tempdir, onerror=handle_readonly) + # Windows rmtree might fail the first time + for _ in range(5): + try: + shutil.rmtree(self.tempdir, onerror=handle_readonly) + except Exception: + pass def test_extractall_preserve_none(self): umask = os.umask(0)