Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-26774: Instrument-finding code incorrectly requires a data query #88

Merged
merged 1 commit into from
Sep 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions python/lsst/utils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import psutil
import functools
import tempfile
import shutil

__all__ = ["init", "MemoryTestCase", "ExecutablesTestCase", "getTempFilePath",
"TestCase", "assertFloatsAlmostEqual", "assertFloatsNotEqual", "assertFloatsEqual",
Expand Down Expand Up @@ -811,3 +812,15 @@ def wrapper(self, *args, **kwargs):
func(self, *args, **kwargs)
return wrapper
return decorator


@contextlib.contextmanager
def temporaryDirectory():
"""Context manager that creates and destroys a temporary directory.

The difference from `tempfile.TemporaryDirectory` is that this ignores
errors when deleting a directory, which may happen with some filesystems.
"""
tmpdir = tempfile.mkdtemp()
yield tmpdir
shutil.rmtree(tmpdir, ignore_errors=True)