Source code
Revision control
Copy as Markdown
Other Tools
import contextlib
import shutil
import tempfile
# This helper can be replaced by pytest tmpdir fixture
@contextlib.contextmanager
def tempdir():
dest_dir = tempfile.mkdtemp()
try:
yield dest_dir
finally:
shutil.rmtree(dest_dir, ignore_errors=True)