Skip to content

Commit

Permalink
Add option to not remove temporary directories
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 committed Dec 1, 2023
1 parent c174c40 commit e4ad48b
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()

Check warning on line 42 in python/sdist/amici/testing.py

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/testing.py#L42

Added line #L42 was not covered by tests

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

Check warning on line 46 in python/sdist/amici/testing.py

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/testing.py#L46

Added line #L46 was not covered by tests

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

0 comments on commit e4ad48b

Please sign in to comment.