Skip to content

Commit

Permalink
Add option to not remove temporary directories (#2221)
Browse files Browse the repository at this point in the history
Convenient for debugging purposes in order to keep directories without rewriting a test using a tempdir.
  • Loading branch information
dweindl authored Dec 3, 2023
1 parent a973bc0 commit 81872cc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/sdist/amici/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,19 @@ class TemporaryDirectoryWinSafe(TemporaryDirectory):
such failures.
"""

def __init__(self, *args, delete=True, **kwargs):
super().__init__(*args, **kwargs)
# TODO Python3.12 TemporaryDirectory already has a delete argument
# remove this once we drop support for Python3.11
self.delete = delete

if not self.delete:
self._finalizer.detach()

def cleanup(self):
if not self.delete:
return

try:
super().cleanup()
except PermissionError as e:
Expand Down

0 comments on commit 81872cc

Please sign in to comment.