Skip to content

Commit 416a5cc

Browse files
[tooling] Fix Permission Error [WinError32] during cleanup (git-mastery#253)
1 parent d085c7b commit 416a5cc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

exercise_utils/test.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,21 @@ def __exit__(
208208
for patch in self.__patches:
209209
patch.stop()
210210

211-
if self.__temp_dir is not None:
212-
self.__temp_dir.cleanup()
211+
if self.__rs and self.__rs.repo:
212+
self.__rs.repo.close()
213+
if self.__rs_remote and self.__rs_remote.repo:
214+
self.__rs_remote.repo.close()
213215

214216
if self.__rs_context is not None:
215217
self.__rs_context.__exit__(exc_type, exc_val, None)
216218

217219
if self.__rs_remote_context is not None:
218220
self.__rs_remote_context.__exit__(exc_type, exc_val, None)
219221

222+
if self.__temp_dir is not None:
223+
os.chdir(Path(self.__temp_dir.name).parent)
224+
self.__temp_dir.cleanup()
225+
220226
if self.__remote_temp_dir is not None:
221227
self.__remote_temp_dir.cleanup()
222228

0 commit comments

Comments
 (0)