Skip to content

Commit

Permalink
Remove temporary_directory() utility function
Browse files Browse the repository at this point in the history
Since we now require Python 3, web services can
instead use the standard library function
tempfile.TemporaryDirectory().
  • Loading branch information
benmwebb committed Jul 6, 2021
1 parent c062a5e commit 911b984
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions python/saliweb/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,6 @@ def working_directory(workdir):
os.chdir(origdir)


@contextlib.contextmanager
def temporary_directory(dir=None):
"""Simple context manager to make a temporary directory.
The temporary directory has the same lifetime as the context manager
(i.e. it is created at the start of the 'with' block, and deleted
at the end of the block).
@param dir If given, the temporary directory is made as a subdirectory
of that directory, rather than in the default temporary
directory location (e.g. /tmp)
@return the full path to the temporary directory.
"""
tmpdir = tempfile.mkdtemp(dir=dir)
yield tmpdir
shutil.rmtree(tmpdir, ignore_errors=True)


class _TempDir(object):
"""Make a temporary directory that is deleted when this object is."""

Expand Down

0 comments on commit 911b984

Please sign in to comment.